aboutsummaryrefslogtreecommitdiff
path: root/web/poc_jsonrpc/nowplaying.html
diff options
context:
space:
mode:
Diffstat (limited to 'web/poc_jsonrpc/nowplaying.html')
-rw-r--r--web/poc_jsonrpc/nowplaying.html63
1 files changed, 36 insertions, 27 deletions
diff --git a/web/poc_jsonrpc/nowplaying.html b/web/poc_jsonrpc/nowplaying.html
index b64059447f..e2f787e9ae 100644
--- a/web/poc_jsonrpc/nowplaying.html
+++ b/web/poc_jsonrpc/nowplaying.html
@@ -34,41 +34,50 @@ function refresh()
setTimeout( "refresh()", 5*1000 );
var http_request = new XMLHttpRequest();
http_request.open( "POST", "jsonrpc", false );
-http_request.send("{\"jsonrpc\": \"2.0\", \"method\": \"Playlist.GetItems\", \"params\": { \"fields\": [\"title\", \"plot\"] }, \"id\": 1}");
+http_request.send("{\"jsonrpc\": \"2.0\", \"method\": \"Player.GetActivePlayers\", \"id\": 1}");
-var the_object = JSON.parse(http_request.responseText);
-var result = the_object["result"];
-var activeItem = result["current"];
-var array = result["items"];
+var players = JSON.parse(http_request.responseText)["result"];
+if (players.length > 0) {
+ var player = players[0];
-if (activeItem >= 0) {
- if (array[activeItem]["thumbnail"])
- document.write("<img src=\"thumb/" + array[activeItem]["thumbnail"] + ".jpg\"></img>");
- else
- document.write("<img src=\"images/DefaultAlbumCover.png\"></img>");
+ http_request = new XMLHttpRequest();
+ http_request.open( "POST", "jsonrpc", false );
+ http_request.send("{\"jsonrpc\": \"2.0\", \"method\": \"Playlist.GetItems\", \"params\": { \"fields\": [\"title\", \"plot\"] }, \"id\": 1}");
- document.write("<br></br>");
+ var the_object = JSON.parse(http_request.responseText);
+ var result = the_object["result"];
+ var activeItem = result["current"];
+ var array = result["items"];
- document.write("<img src=\"images/OSDPrevTrackFO.png\" onclick=CallMethod(\"Player.SkipPrevious\")></img>");
- document.write("<img src=\"images/OSDStopFO.png\" onclick=CallMethod(\"Player.Stop\")></img>");
- document.write("<img src=\"images/OSDPlayFO.png\" onclick=CallMethod(\"Player.PlayPause\")></img>");
- document.write("<img src=\"images/OSDNextTrackFO.png\" onclick=CallMethod(\"Player.SkipNext\")></img>");
+ if (activeItem >= 0) {
+ if (array[activeItem]["thumbnail"])
+ document.write("<img src=\"thumb/" + array[activeItem]["thumbnail"] + ".jpg\"></img>");
+ else
+ document.write("<img src=\"images/DefaultAlbumCover.png\"></img>");
- document.write("<br></br>");
+ document.write("<br></br>");
- document.write("<table class=\"Playlist\"><tbody>");
- for (var i in array) {
- var item = array[i];
+ document.write("<img src=\"images/OSDPrevTrackFO.png\" onclick=CallMethod(\"" + player + "Player.SkipPrevious\")></img>");
+ document.write("<img src=\"images/OSDStopFO.png\" onclick=CallMethod(\"" + player + "Player.Stop\")></img>");
+ document.write("<img src=\"images/OSDPlayFO.png\" onclick=CallMethod(\"" + player + "Player.PlayPause\")></img>");
+ document.write("<img src=\"images/OSDNextTrackFO.png\" onclick=CallMethod(\"" + player + "Player.SkipNext\")></img>");
- document.write("<tr class=\"" + (i % 2 == 0 ? "even" : "odd") + "\">");
- document.write("<td class=\"label\">" + item["label"] + "</td>");
- if (i == activeItem)
- document.write("<td class=\"playing\"><img src=\"images/play.png\" height=16></img></td>");
- else
- document.write("<td class=\"playing\"></td>");
- document.write("</tr>");
+ document.write("<br></br>");
+
+ document.write("<table class=\"Playlist\"><tbody>");
+ for (var i in array) {
+ var item = array[i];
+
+ document.write("<tr class=\"" + (i % 2 == 0 ? "even" : "odd") + "\">");
+ document.write("<td class=\"label\">" + item["label"] + "</td>");
+ if (i == activeItem)
+ document.write("<td class=\"playing\"><img src=\"images/play.png\" height=16></img></td>");
+ else
+ document.write("<td class=\"playing\"></td>");
+ document.write("</tr>");
+ }
+ document.write("</tbody></table>");
}
- document.write("</tbody></table>");
} else {
document.write("Nothings playing");
}