diff options
-rw-r--r-- | lib/general.js | 36 | ||||
-rw-r--r-- | server/ajax.server.php | 1 | ||||
-rw-r--r-- | templates/show_mpdplay.inc | 12 |
3 files changed, 21 insertions, 28 deletions
diff --git a/lib/general.js b/lib/general.js index a5100222..444029d2 100644 --- a/lib/general.js +++ b/lib/general.js @@ -66,30 +66,34 @@ function handleStateChange() { } // end if mpd changed player_state break; case 'now_playing' : + ret_songid = Math.round(el.getElementsByTagName ('songid')[0].firstChild.data); if (player == 'mpd' && player_state != 'stop') { mpd_song_length = el.getElementsByTagName ('songlength')[0].firstChild.data; - ret_songid = Math.round(el.getElementsByTagName ('songid')[0].firstChild.data); + document.getElementById ('mpd_npinfo').firstChild.data = + 1+ret_songid + ". " + + el.getElementsByTagName ('songartist')[0].firstChild.data + " - " + + el.getElementsByTagName ('songtitle')[0].firstChild.data + " - " + + el.getElementsByTagName ('songalbum')[0].firstChild.data + " - " + + fmt_time(mpd_song_length); + } if (ret_songid != mpd_songid) { if (document.getElementById ('mpd_row'+mpd_songid) != null) { if ((mpd_songid - mpdpl_first) %2 == 1) { - document.getElementById ('mpd_row'+mpd_songid).className = 'even'; + document.getElementById ('mpd_row'+mpd_songid).className = 'even'; } else { - document.getElementById ('mpd_row'+mpd_songid).className = 'odd'; - } + document.getElementById ('mpd_row'+mpd_songid).className = 'odd'; } - if (document.getElementById ('mpd_row'+ret_songid) != null) { - document.getElementById ('mpd_row'+ret_songid).className = 'npsong'; - } - mpd_songid = ret_songid; } - document.getElementById ('mpd_npinfo').firstChild.data = - 1+mpd_songid + ". " + - el.getElementsByTagName ('songartist')[0].firstChild.data + " - " + - el.getElementsByTagName ('songtitle')[0].firstChild.data + " - " + - el.getElementsByTagName ('songalbum')[0].firstChild.data + " - " + - fmt_time(mpd_song_length); - } - break; + if (player_state != 'stop') { + + if ((document.getElementById ('mpd_row'+ret_songid) != null) && (player_state != 'stop')) { + document.getElementById ('mpd_row'+ret_songid).className = 'npsong'; + } + } + + mpd_songid = ret_songid; + } + break; case 'now_playing_display' : // fix for pages where now playing data doesnt exist if (document.getElementById('np_songid_0_holder')) { diff --git a/server/ajax.server.php b/server/ajax.server.php index 04394f45..71a36d27 100644 --- a/server/ajax.server.php +++ b/server/ajax.server.php @@ -138,6 +138,7 @@ case 'adjvol' : if ( is_null($myMpd->Pause()) ) echo "ERROR: " .$myMpd->errStr."\n"; mpd_cur_track_pos(); state(); + now_playing(); break; case '|< ': case "Prev": diff --git a/templates/show_mpdplay.inc b/templates/show_mpdplay.inc index 89a9b89b..30274a9c 100644 --- a/templates/show_mpdplay.inc +++ b/templates/show_mpdplay.inc @@ -172,16 +172,4 @@ global $condPL; </td> </tr> </table> -<?php -/***** moving this into javascript_refresh.js - -echo '<script language="JavaScript" type="text/javascript"> var mpd_elapsed = '. $myMpd->current_track_position. - '; var mpd_song_length = '. $myMpd->current_track_length . - '; var mpd_songid = '.$myMpd->current_track_id. - '; var mpd_state = "'. $myMpd->state .'"; </script>'; - -****** end move -******/ - -?> </div> |