aboutsummaryrefslogtreecommitdiff
path: root/web/poc_jsonrpc/nowplaying.html
blob: b64059447f677a48bdee566ad3251ea552f45d4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<html>
<head>
<title>XBMC - Now playing</title>
<link type="text/css" rel="stylesheet" href="basic.css" />
<script type="text/javascript" src="json.js" />
<script type="text/javascript">
function CallMethod(method)
{
  var http_request = new XMLHttpRequest();
  http_request.open( "POST", "jsonrpc", false );
  http_request.send("{\"jsonrpc\": \"2.0\", \"method\": \"" + method + "\", \"params\": { \"fields\": [\"title\", \"plot\"] }, \"id\": 1}");
  window.location.reload( false );
}

function refresh()
{
  window.location.reload( false );
}
</script>

</head>
<body>
<table class="Navigation">
<tr class="primary">
  <td class="selected"><a href="nowplaying.html">Now playing</a></td>
  <td class="unselected"><a href="movies.html">Videos</a></td>
  <td class="unselected"><a href="artists.html">Music</a></td>
  <td class="unselected"><a href="development.html">Development</a></td>
</tr>
</table>
<br />

<script type="text/javascript">
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}");

var the_object = JSON.parse(http_request.responseText);
var result = the_object["result"];
var activeItem = result["current"];
var array = result["items"];

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("<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>");

  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>");
} else {
  document.write("Nothings playing");
}
</script>
</body>
</html>