Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

playing consecutive sounds

Status
Not open for further replies.

SlykFX

Programmer
Oct 12, 2002
76
GB
i have three sound files that I want to play consecutivly.

Is this possible? I can't be bothered to have a sig!
 
What exactly do you want? Do you want to have background music for your page that continually loops through those three sounds? Or do you want to play the sounds on a link click? Do you want to play each sound once only or have it continually play them 3 at a time?

It is possible to do this, and I can show you how after getting some more info, but why don't you just combine the sound files in to one file?

You can download cooledit from here if you don't have a sound file editing program:

Rick
 
when the page loads, each sound file is played through once

eg.
Page loads
sound1.wav is played
sound2.wav is played
sound3.wav is played

i need to keep them as seperate files because this is just one part of an ever changing script
I can't be bothered to have a sig!
 
Ok. Here is one way to do it with javascript, but beware that wav files take a long time to load on a dialup connection:

<html>
<script>
<!--

function play(i){
var sounds = new Array(&quot;sound1.wav&quot;,&quot;sound2.wav&quot;,&quot;sound3.wav&quot;);//names of the files
var times = new Array(&quot;5&quot;,&quot;10&quot;,&quot;23&quot;);//length of the file in seconds
document.getElementById(&quot;bg_sound&quot;).src=sounds;
if(i<sounds.length){
i++;
setTimeout('play('+i+')',times[i-1]*1000 + 1000);//the length (in miliseconds) of the last song + 1
//second padding before playing the next sound
}
}

//-->
</script>
<body onLoad=&quot;play(0)&quot;>
<bgsound id=&quot;bg_sound&quot;>

</body>
</html>

I can see some problems coming up with the load time taking longer than the length of the song, but I don't know how to fix that.
 
thanks for that :)

ive precached the sounds on the previous page so the load time is not a problem

I can't be bothered to have a sig!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top