I have 6 sound files (1.wav 2.wav etc..) of which 3 different ones have to be heard each time the web page opens. The numbers are selected randomly. I have tried multiple "embeds" but only the last sound selected gets produced. I have also tried javascript routines that fiddle the bgsound attribute, however, I was not able to produce more than one sound at a time. The sounds are required to play either automatically on page open or they can be triggered by a click on a button or link, however, only one click is acceptable for the three sounds. Is there another way to do this? suggestions very welcome.
I would use Flash if i'm trying to add sound into a webpage, you can embed a flash document with no width or height so it will be invisible but still play noise.
I've got a good idea: DON'T!
I hate web sites that play sounds without my telling them to. I use a multi-tabbed browser, and a multi-tasking operating system, and you don't have control of my computer, so don't assume you can play a sound without interfering with other things I'm doing.
A browser will split page loading into multiple items and thus it's likely to load all sounds at once using multiple threads. I think what you're trying to accomplish is impossible.
A simple Flash would do the trick better than anything else. However please consider that unless you develop your page for the Intranet application and the feature was specifically requested by the users it will most likely go against the best usability practices for web. Most users consider the pages which produce sounds to be very distractive and if the sound is produced on the page load the most likely will not be able to turn it off. If you want to embed some sound in your page you may allow the user to turn it on explicitely.
I know this is a bit exorbitant, but the number of combinations are not overly excessive. If you pre-blend the wav files into a series of files and just name them as follows
1_2_3, 1_2_3, 1_2_5, 1_2_6
1_3_4, 1_3_5, 1_3_6
1_4_5, 1_4_6
2_3_4, 2_3_5, 2_3_6,
2_4_5, 2_4_6,
2_5_6
3_4_5, 3_4_6,
3_5_6,
4_5_6
( fortunately not too many combinations )
and then as long as you do:
$n = [ randomnumber , randomnumber , randomnumber ];
$n = sort $n;
file = "$n[0]_$n[1]_$n[2].wav"
that should get it working.
Noted many people are opposed to sound and depending on what technique you use to play it it may/may not work for all, but that's probably a feature we should get browsers to enforce, because some people like being able to hear sounds ( shocking, but true ).
If you're not against using a JavaScript framework to play a sound scriptaculous provides an API for playing sounds.
Adding Sounds - HTML Lessons HTML MUSIC / MEDIA CODE - Sound http://html-lesson.blogspot.com/2008/06/music-media-code-sound.html
Check out Sound Manager 2 an invisible flash movie that you can use to play sounds. It allows you to load and play multiple sounds.
To do what you wish to accomplish I would re-encode the wav files as mp3s (so that they download faster and Sound Manager can play them). Then use javascript to get sound manager to create the sounds and play them in a random order. You can listen to the onfinish event of each sound to start playing the next sound.