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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can someone tell me what goes wrong

Status
Not open for further replies.

rnby

Technical User
Jan 25, 2005
8
BE
<html>
<head>
<script language="javascript">


function sivamtime() {
var hour1 = 10;
var min1 = 10;
var sec1 = 10;
var straddr = "<!--#echo var="DATE_LOCAL"-->";
var sec = (straddr.charAt(straddr.length - 6) +
straddr.charAt(straddr.length - 5));
var min = (straddr.charAt(straddr.length - 9) +
straddr.charAt(straddr.length - 8));
var hour = (straddr.charAt(straddr.length - 12) +
straddr.charAt(straddr.length - 11));

document.write(""+hour+":"+min+":"+sec+"");
document.write("<br>");
document.write(""+hour1+":"+min1+":"+sec1+"");
document.write("<hr>");
document.write("<br>");

if (hour>hour1) {
newhour=hour-hour1;
} else if (hour<hour1) {
temphour=24-hour1;
temphour2=temphour-hour
if (temphour2<0) {
newhour=24+temphour2-4;
} else {
newhour=24+temphour2-4
}
} else {
newhour=0;
}
//end of hours

//start of minutes
if (min>min1) {
newmin=min-min1;
} else if (min<min1) {
tempmin1=60-min;
tempmin2=tempmin1+min1;
newmin=tempmin2-20;
} else {
newmin=0
}
//end of minutes

//start of seconds
if (sec>sec1) {
newsec=sec-sec1;
} else if (sec<sec1) {
tempsec1=60-sec;
tempsec2=tempsec1+sec1;
newsec=tempsec2-20;
} else {
newsec=0
}

document.write(newhour);
document.write(":");
document.write(newmin);
document.write(":");
document.write(newsec);
document.write("<br>");
document.write("<hr>");
document.write("<br>");

//convert total time to seconds

var tst1=newhour*1200;
var tst2=newmin*60;
var tst3=tst1+tst2;
var totalsec=tst3+newsec;
document.write(tst1);
document.write("<br>");
document.write(tst2);
document.write("<br>");
document.write(totalsec);
document.write("<hr><hr>");

//playlist with musicname and time

function music(name,length,title) {
this.name=name; this.length=length
}

var line = new Array()
line[0] = new music('muziek',20)
line[1] = new music('muziek2',15)
line[2] = new music('muziek3',30)
line[3] = new music('muziek',20)
line[4] = new music('muziek2',15)
line[5] = new music('muziek3',30)
line[6] = new music('muziek',20)
line[7] = new music('muziek2',15)
line[8] = new music('muziek3',30)
line[9] = new music('muziek',20)
line[10] = new music('muziek2',15)
line[11] = new music('muziek3',30)
line[12] = new music('muziek',20)
line[13] = new music('muziek2',15)
line[14] = new music('muziek3',30)
line[15] = new music('muziek',20)
line[16] = new music('muziek2',15)
line[17] = new music('muziek3',30)
line[18] = new music('muziek',20)
line[19] = new music('muziek2',15)
line[20] = new music('muziek3',30)
line[21] = new music('muziek',20)
line[22] = new music('muziek2',15)
line[23] = new music('muziek3',30)
line[24] = new music('muziek',20)
line[25] = new music('muziek2',15)
line[26] = new music('muziek3',30)
line[27] = new music('muziek',20)
line[28] = new music('muziek2',15)
line[29] = new music('muziek3',30)
line[30] = new music('muziek',20)
line[31] = new music('muziek2',15)
line[32] = new music('muziek3',30)
line[33] = new music('muziek',20)
line[34] = new music('muziek2',15)
line[35] = new music('muziek3',30)
line[36] = new music('muziek',20)
line[37] = new music('muziek2',15)
line[38] = new music('muziek3',30)
line[39] = new music('muziek',20)
line[40] = new music('muziek2',15)
var playlist= 0;
var time=totalsec;
var songnumber=0;
document.write(playlist+"<BR>");
document.write(songnumber+"<BR>");
document.write(time+"<BR>");

while (time > playlist) {
playlist=playlist+line[songnumber].length;
document.write(playlist+"<BR>");

var musicsrc="[songnumber].name+".mp3";
document.write('<bgsound src='+'"'+musicsrc+'">')
alert(songnumber);
}

timeout1()



}

function timeout1(){
var b_songlength=line[songnumber].length;
var q_songlength=b_songlength*1000;
setTimeout('player()',q_songlength);
++songnumber;}

function player(){
var musicsrc="[songnumber].name+".mp3";
document.write('<bgsound src="'+musicsrc+'">');
alert(songnumber);
timeout1()}
//}



</script>
</head>
<body onload="sivamtime()">

<script language="javascript">

</script>



</body>
</html>
 
> Can someone tell me what goes wrong

My first guess would be - a lot.

What are you trying to do and why are you writing so many <bgsound> tags to the page? You've got the same song playing over itself so many times, that the first time I heard it, I thought I was listening to "death metal" (not kidding!). It turned out to be some old-sounding folk song.



Adam
 
what i'm trying is to have on my page musicplaying.
I have a playlist and i want it to go through the playlist.
the script takes the time from the server

var straddr = "<!--#echo var="DATE_LOCAL"-->";

and compares with the starttime of the playlist.

var hour1 = 10;
var min1 = 10;
var sec1 = 10;
because i want everybody to hear the same music the same time, i have the diferent between the starttime and the time now (from the server) and then i want him to loop through the playlist to see till what song he is up to.
the he needs to play that song, and i have a timeout that should take the time of the current playing song and when this song is finished he shoulod add 1 to the songnumber.
i hope you can help me as i cant find a way to get it to work like it should.
instead of going to the next song it stays by the same song and the timeout also doesnt work it, that's why it comes to play so much times, because he plays it over and over again
thanksk a lot for your help
RNBY
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top