Playsound onload

matty1980

New Member
Messages
6
Reaction score
0
Points
0
I want to use javascript to play a sound when my site loads and then give the user the option to stop it using an onClick event. However my programming skills are not the best here is what i got so far:

<script type="text/javascript">
var soundfile="/media-bin/REM.mp3"

function playsound() {

}
</script>


</head>
<body onLoad="playsound()">

Any help would be appreciate
 

cybrax

Community Advocate
Community Support
Messages
764
Reaction score
27
Points
0
There are a few ways of doing this but probably the best is to use FLASH. Otherwise the visitor will get the annoying 'ActiveX warning' or 'Install Missing Plugin' pop-up when the sound event triggers, as most people have flash player installed for other applications it makes sense and it means your page will behave the way you want regardless of visitors browser.
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
There are a few ways of doing this but probably the best is to use FLASH. Otherwise the visitor will get the annoying 'ActiveX warning' or 'Install Missing Plugin' pop-up when the sound event triggers, as most people have flash player installed for other applications it makes sense and it means your page will behave the way you want regardless of visitors browser.

Very true, but I also just want to jump in and make a polite advisory to the original poster as well: Many people (myself included) will close the site as soon as music or other sound effects begin playing. In my case, the music on the website tends not to mesh with the music already playing in XMPlay.

Just adding that in; make sure the crowd you're trying to cater to actually wants music on the homepage, or you might find yourself getting tons of 1-view hits that leave and never come back.
 

cybrax

Community Advocate
Community Support
Messages
764
Reaction score
27
Points
0
Well said that avatar from the artic, having sound play when the page has finished loading is a design no-no for professional web sites but you still find a lot of hobby sites using this trick.

People like to be in control, so give them the option to have music on or off if they want it.

Flash /MP3/wav files wether it music or video are quite large and this comes out of your websites monthly traffic allowance but if Flash is used then you can perform what is known as embedded content.

In a nutshell the files come from somebody elses server not x10's and is perfectly legal and it is just a case of cut an paste the code to get the tracks and a player all in one go. Below is real example of some Drum & Bass from the Internet Archive but you use You Tube or many others.

http://shambles.x10hosting.com/flash%20sound%20demo.html
 
Top