Since you asked, I'll share it with you however it's
NOT plug'n'play you'll have to figure out how to incorporate it into your web page. My site is ajax based.
basic function:
(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
<script type="text/javascript">
function countDown()
{
countDownTime--;
if ( countDownTime == 0 )
{
countDownTime = countDownInterval;
if ( window.parent.active_module == "Now Playing" )
{
window.parent.getNowPlaying();
}
window.location.reload();
return;
}
else if ( countDownTime < 0 )
{
countDownTime = 10;
}
if ( window.parent.document.getElementById( "countDownText" ) )
{
window.parent.document.getElementById( "countDownText" ).innerHTML = secsToMins( countDownTime );
}
}
function secsToMins( theValue )
{
var theMin = Math.floor( theValue / 60 );
var theSec = ( theValue % 60 );
if ( theSec < 10 )
{
theSec = "0" + theSec;
}
return( theMin + ":" + theSec );
}
var countDownInterval = <?php echo( $secs_remain ); ?>;
var countDownTime = countDownInterval + 1;
setInterval ( "countDown();", 1000 );
</script>
Create statement for now playing view
(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `samdb`.`fhr_now_playing_view` AS select `s`.`ID` AS `song_id`,`h`.`requestID` AS `requestID`,`s`.`artist` AS `artist`,`s`.`fhr_artistID` AS `artist_id`,`s`.`album` AS `album`,`s`.`fhr_albumID` AS `album_id`,`s`.`title` AS `title`,`s`.`duration` AS `duration`,`s`.`albumyear` AS `album_year`,`s`.`genre` AS `genre`,`s`.`composer` AS `composer`,`s`.`trackno` AS `trackno`,`s`.`lyrics` AS `lyrics`,`s`.`info` AS `info`,`s`.`picture` AS `picture`,`s`.`count_played` AS `count_played`,`s`.`count_requested` AS `count_requested`,`s`.`last_requested` AS `last_requested`,`s`.`count_performances` AS `count_performances`,`s`.`votes` AS `votes`,`s`.`rating` AS `rating`,`s`.`songtype` AS `songtype`,`s`.`date_added` AS `date_added`,`s`.`date_played` AS `date_played`,unix_timestamp() AS `database_time` from (`samdb`.`songlist` `s` join `samdb`.`historylist` `h`) where ((`s`.`ID` = `h`.`songID`) and ((`s`.`songtype` = _latin1'S') or (`s`.`songtype` = _latin1'C') or (`s`.`songtype` = _latin1'V'))) order by `h`.`ID` desc limit 1;
setup
(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
$result = mysqli_query( $samDB, "select * from fhr_now_playing_view" );
$now_playing = mysqli_fetch_array( $result );
$secs_remain = ( round( $now_playing["duration"] / 1000 ) - (( $now_playing["database_time"]) - strtotime($now_playing["date_played"] ) ) );
$secs_remain = $secs_remain-2;
actual display of the countdown timer next to the now playing track info
(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
<tr>
<td align=right><b>Duration:</b></td>
<td> </td>
<td align=left><?php echo( $mmss ); ?> (Remain: <b id="countDownText"></b>)</td>
</tr>