View Full Version : Play the next track when the current one finishes

08-29-2007, 04:10 AM
Hey guys, i'm currently doing a website that required random background music. But now im facing a problem where how can i modify my current script so that it will auto play the next track instead of looping the current track? Im kinda new to this. thanks in advance =)

var sound1="sounds/2001spce.mid"
var sound2="sounds/20fox.mid"
var sound3="sounds/9010v2.mid"
var sound4="sounds/adam.mid"
var sound5="sounds/apollo13.mid"
var sound6="sounds/airwolf.mid"
var sound7="sounds/btfuture.mid"
var sound8="sounds/baywatch.mid"
var sound9="sounds/chicagobull.mid"
var sound10="sounds/xfile.mid"
var x=Math.round(Math.random()*9)
if (x==0) x=sound1
else if (x==1) x=sound2
else if (x==2) x=sound3
else if (x==3) x=sound4
else if (x==4) x=sound5
else if (x==5) x=sound6
else if (x==6) x=sound7
else if (x==7) x=sound8
else if (x==8) x=sound9
else x=sound10

if (navigator.appName=="Microsoft Internet Explorer")
document.write('<bgsound src='+'"'+x+'"'+' loop="infinite">')
document.write('<embed src='+'"'+x+'"'+'hidden="true" border="0" width="20" height="20" autostart="true" loop="true">')