You don't need to count down.
on _config.html
set the line
from
Code:
<!--VAL(timeout,"30000$")-->
to
Code:
<!--VAL(timeout,"$song.duration$")-->
into _playing.html
from
Code:
<script type="text/javascript">
//<![CDATA[
/*
var refreshID = "";
refreshID = setTimeout("DoRefresh()", $timeout$);
function DoRefresh()
{
var buster = Math.random();
document.location.href = 'playing.html?buster='+buster;
}
*/
//]]>
</script>
to
Code:
<script type="text/javascript">
//<![CDATA[
/*
var RefreshTime= $timeout$ ;
var refreshID = "";
refreshID = setTimeout("DoRefresh()", RefreshTime);
function DoRefresh()
{
var buster = Math.random();
document.location.href = 'playing.html?buster='+buster;
}
*/
//]]>
</script>
to overcome the inertia of the upload, I do suggest this line in the following way:
Code:
var RefreshTime= $timeout$ + 5000;
It adds 5 seconds, in order to extend a bit the refresh, giving the time to SAM to upload to the server
This value is up to you. I strongly suggest do not be higher than 5 seconds ... the less, the better
However I updated the whole code with this one:
Code:
<script type="text/javascript">
//<![CDATA[
function autoReload() {
var RefreshTime = ( $timeout$ ) + 5000;
setTimeout(function() {
var rand = Math.random();
var address = 'playing.html?rand='+rand;
$.ajax({
url: 'playing.html?rand='+rand,
success: function(data) {
location.reload(address);
}
});
autoReload(); // calling again after the duration of the song expired
}, RefreshTime );
}
autoReload(); // calling the function for the first time
//]]>
</script>
Of course this way can be not precise at all, but it refreshes the page following the duration of the song.