Hi,
I am using this customised script to display the countodwon of the songs.
Using Linux server, SQL4.1 and php+java
//tables in MYSQL
`date_played` datetime NOT NULL default '0000-00-00 00:00:00',
`duration` mediumint(9) NOT NULL default '0',
//examples of data
dateplayed: 2005-09-04 17:34:13
duration: 213259 = 3.554 sec (3.55*60*1000)
//variables
$curtime = time();
$starttime = strtotime($song["date_played"]);
$secsRemain = (round($song["duration"] / 1000)-($curtime-$starttime));
//script
<script language="JavaScript">
var countDownTime = <? echo $secsRemain; ?> + 1;
var countDownR = <? if ($userdata['user_id'] == 1) echo 10; else echo rand (30, 120); ?> + 1;
if (document.all||document.getElementById)
countDown();
else
window.onload = countDown;
function countDown() {
if (document.all)
document.all.countDownText.innerText = "Time left";
else if (document.getElementById)
document.getElementById("countDownText").innerHTML = "Time left";
countDownTime--;
if (countDownTime == 0) {
countDownRe();
return;
}
else if (countDownTime < 0)
countDownTime = 30;
if (document.all)
document.all.countDownTime.innerText = secsToMins(countDownTime);
else if (document.getElementById)
document.getElementById("countDownTime").innerHTML = secsToMins(countDownTime);
counter = setTimeout("countDown()", 1000);
}
function countDownRe() {
if (document.all)
document.all.countDownText.innerText = "Reload in";
else if (document.getElementById)
document.getElementById("countDownText").innerHTML = "Reload in";
countDownR--;
if (countDownR == 0) {
window.location.reload();
return;
}
else if (countDownR < 0)
countDownR = 30;
if (document.all)
document.all.countDownTime.innerText = secsToMins(countDownR);
else if (document.getElementById)
document.getElementById("countDownTime").innerHTML = secsToMins(countDownR);
counter = setTimeout("countDownRe()", 1000);
}
function secsToMins(theValue) {
var theMin = Math.floor(theValue / 60);
var theSec = (theValue % 60);
if (theSec < 10)
theSec = "0" + theSec;
return(theMin + ":" + theSec);
}
</script>
The problem I am having is that instead the countdown should start say for example above from 3:55 secs, it always starts from 30 secs.... and duration still it strts from 30sec.
Any help or suggestion would be appreciated
I am using this customised script to display the countodwon of the songs.
Using Linux server, SQL4.1 and php+java
//tables in MYSQL
`date_played` datetime NOT NULL default '0000-00-00 00:00:00',
`duration` mediumint(9) NOT NULL default '0',
//examples of data
dateplayed: 2005-09-04 17:34:13
duration: 213259 = 3.554 sec (3.55*60*1000)
//variables
$curtime = time();
$starttime = strtotime($song["date_played"]);
$secsRemain = (round($song["duration"] / 1000)-($curtime-$starttime));
//script
<script language="JavaScript">
var countDownTime = <? echo $secsRemain; ?> + 1;
var countDownR = <? if ($userdata['user_id'] == 1) echo 10; else echo rand (30, 120); ?> + 1;
if (document.all||document.getElementById)
countDown();
else
window.onload = countDown;
function countDown() {
if (document.all)
document.all.countDownText.innerText = "Time left";
else if (document.getElementById)
document.getElementById("countDownText").innerHTML = "Time left";
countDownTime--;
if (countDownTime == 0) {
countDownRe();
return;
}
else if (countDownTime < 0)
countDownTime = 30;
if (document.all)
document.all.countDownTime.innerText = secsToMins(countDownTime);
else if (document.getElementById)
document.getElementById("countDownTime").innerHTML = secsToMins(countDownTime);
counter = setTimeout("countDown()", 1000);
}
function countDownRe() {
if (document.all)
document.all.countDownText.innerText = "Reload in";
else if (document.getElementById)
document.getElementById("countDownText").innerHTML = "Reload in";
countDownR--;
if (countDownR == 0) {
window.location.reload();
return;
}
else if (countDownR < 0)
countDownR = 30;
if (document.all)
document.all.countDownTime.innerText = secsToMins(countDownR);
else if (document.getElementById)
document.getElementById("countDownTime").innerHTML = secsToMins(countDownR);
counter = setTimeout("countDownRe()", 1000);
}
function secsToMins(theValue) {
var theMin = Math.floor(theValue / 60);
var theSec = (theValue % 60);
if (theSec < 10)
theSec = "0" + theSec;
return(theMin + ":" + theSec);
}
</script>
The problem I am having is that instead the countdown should start say for example above from 3:55 secs, it always starts from 30 secs.... and duration still it strts from 30sec.
Any help or suggestion would be appreciated