mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-05 19:41:55 +02:00
now playing stuff
This commit is contained in:
parent
2d5ed879bd
commit
1f5748db2b
3 changed files with 253 additions and 73 deletions
|
@ -15,7 +15,7 @@ function createXMLHttpRequest() {
|
|||
function startRequest(params) {
|
||||
createXMLHttpRequest();
|
||||
xmlHttp.onreadystatechange = handleStateChange;
|
||||
xmlHttp.open("GET", "server/ajax.server.php?"+params, true);
|
||||
xmlHttp.open("GET", "server/ajax.server.php?"+params+"&player="+player, true);
|
||||
/* xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); */
|
||||
xmlHttp.send(null);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ alert ("mpd_elapsed ="+fmt_time(mpd_elapsed)+"; nowtime - starttime ="+fmt_time(
|
|||
function handleStateChange() {
|
||||
if (xmlHttp.readyState == 4) {
|
||||
if (xmlHttp.status == 200) {
|
||||
/* alert ("responseText = " + xmlHttp.responseText); */
|
||||
/* alert ("responseText = " + xmlHttp.responseText); */
|
||||
var props = xmlHttp.responseXML.getElementsByTagName("properties")[0].childNodes;
|
||||
|
||||
for (var i=1; i< props.length; i++) {
|
||||
|
@ -38,7 +38,7 @@ function handleStateChange() {
|
|||
case 'action' : break;
|
||||
case 'volume' :
|
||||
var vol = el.firstChild.data;
|
||||
document.getElementById ('volume').firstChild.data = vol;
|
||||
if (player == 'mpd') document.getElementById ('volume').firstChild.data = vol;
|
||||
break;
|
||||
case 'mpd_cur_track_pos' :
|
||||
mpd_elapsed = Math.floor(el.firstChild.data);
|
||||
|
@ -55,17 +55,17 @@ function handleStateChange() {
|
|||
document.getElementById (new_state+'_button').className = "selected_button";
|
||||
player_state = new_state;
|
||||
if (player_state == "stop" || player_state == "pause") {
|
||||
if (player == 'mpd') document.getElementById ('mpd_np').className = "nodisplay";
|
||||
document.getElementById ('mpd_np').className = "nodisplay";
|
||||
/* turn off the now playing stuff */
|
||||
} else
|
||||
{
|
||||
if (player == 'mpd') document.getElementById ('mpd_np').className = "";
|
||||
document.getElementById ('mpd_np').className = "";
|
||||
/* turn on the now playing stuff */
|
||||
} // end if else
|
||||
} // end if
|
||||
} // end if mpd changed player_state
|
||||
break;
|
||||
case 'now_playing' :
|
||||
if (player == 'mpd' && (player_state == 'play')) {
|
||||
if (player == 'mpd' && player_state != 'stop') {
|
||||
mpd_song_length = el.getElementsByTagName ('songlength')[0].firstChild.data;
|
||||
mpd_songid = Math.round(el.getElementsByTagName ('songid')[0].firstChild.data);
|
||||
document.getElementById ('mpd_npinfo').firstChild.data =
|
||||
|
@ -74,8 +74,14 @@ function handleStateChange() {
|
|||
el.getElementsByTagName ('songtitle')[0].firstChild.data + " - " +
|
||||
el.getElementsByTagName ('songalbum')[0].firstChild.data + " - " +
|
||||
fmt_time(mpd_song_length);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'now_playing_display' :
|
||||
// fix for pages where now playing data doesnt exist
|
||||
if (document.getElementById('np_songid_0_holder')) {
|
||||
show_now_playing_display(el);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
alert ('Unknown XML reply :"'+el.tagName+'"');
|
||||
} // end switch
|
||||
|
@ -88,6 +94,68 @@ function handleStateChange() {
|
|||
}
|
||||
|
||||
|
||||
// the actual function that checks and updates the now playing data.
|
||||
function show_now_playing_display (el) {
|
||||
for (var i=0; i<el.childNodes.length; i++) {
|
||||
now_playing = el.childNodes[i];
|
||||
|
||||
// check if we need to update
|
||||
if (document.getElementById('np_songid_'+i+'_holder').innerHTML ==
|
||||
now_playing.getElementsByTagName('songid')[0].firstChild.data) { } else {
|
||||
|
||||
// set the songid holder, so we only update if nessicary... (no album art flashing)
|
||||
document.getElementById('np_songid_'+i+'_holder').innerHTML =
|
||||
now_playing.getElementsByTagName('songid')[0].firstChild.data;
|
||||
|
||||
// output the fullname of the person, may be blank
|
||||
document.getElementById('np_fullname_'+i).innerHTML =
|
||||
now_playing.getElementsByTagName('fullname')[0].firstChild.data;
|
||||
|
||||
// output the song name and link tag
|
||||
document.getElementById('np_song_'+i).innerHTML =
|
||||
'<a href="song.php?action=m3u&song=' +
|
||||
now_playing.getElementsByTagName('songid')[0].firstChild.data + '">' +
|
||||
now_playing.getElementsByTagName('songtitle')[0].firstChild.data + '</a>';
|
||||
|
||||
|
||||
// output the artist / album and link tags
|
||||
document.getElementById('np_albumartist_'+i).innerHTML =
|
||||
'<a href="albums.php?action=show&album=' +
|
||||
now_playing.getElementsByTagName('albumid')[0].firstChild.data + '">' +
|
||||
now_playing.getElementsByTagName('songalbum')[0].firstChild.data +
|
||||
'</a> / <a href="artists.php?action=show&artist=' +
|
||||
now_playing.getElementsByTagName('artistid')[0].firstChild.data + '">' +
|
||||
now_playing.getElementsByTagName('songartist')[0].firstChild.data + '</a>';
|
||||
|
||||
// output the album art, and the link for it
|
||||
document.getElementById('np_img_'+i).innerHTML =
|
||||
'<a target="_blank" href="albumart.php?id=' +
|
||||
now_playing.getElementsByTagName('albumid')[0].firstChild.data +
|
||||
'&type=popup" onclick="popup_art(\'albumart.php?id=' +
|
||||
now_playing.getElementsByTagName('albumid')[0].firstChild.data +
|
||||
'&type=popup\'); return false;">' +
|
||||
'<img align="middle" border="0" src="albumart.php?id=' +
|
||||
now_playing.getElementsByTagName('albumid')[0].firstChild.data +
|
||||
'&fast=1&thumb=1" alt="Album Art" height="75" /></a>';
|
||||
|
||||
|
||||
// make sure its visible.
|
||||
document.getElementById('np_container_'+i).style.display = 'block';
|
||||
|
||||
|
||||
} // end if holder = songid
|
||||
} // for ecah record we get
|
||||
|
||||
// fill in the rest with blank data and hide them.
|
||||
while (i<5) {
|
||||
document.getElementById('np_container_'+i).style.display = 'none';
|
||||
document.getElementById('np_songid_'+i+'_holder').innerHTML = '';
|
||||
i++;
|
||||
} // end while i<5
|
||||
|
||||
} // end show_now_playing_display function
|
||||
|
||||
|
||||
function disableField(element) {
|
||||
var element_id = document.getElementById(element);
|
||||
element_id.disabled=true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue