Permalink
Browse files

Merge branch 'master' of git://github.com/nick8888/mediafrontpage

  • Loading branch information...
2 parents 8b76d9f + 22862a9 commit 98a5b7ab96c05d17618de1a24447b14b52d45ff0 @rodneyshupe rodneyshupe committed Nov 7, 2010
Showing with 113 additions and 48 deletions.
  1. +8 −2 css/front.css
  2. +105 −46 widgets/wNowPlaying.php
View
@@ -130,22 +130,28 @@ a.controlbutton img {
display:block;
clear:both;
}
-#nowplaying {
+#nowplayingwrapper {
display:block;
margin: 20px 0 0;
+ height:120px;
}
#thumbblock {
height: 100px;
width: 100px;
padding:0 10px 10px 0px;
float: left;
}
-#nowplaying img {
+#wNowPlaying img {
float: left;
padding: 0 5px 5px 0;
max-height: 100px;
max-width: 100px;
}
+#wNowPlaying .playlist-item {
+ display: block;
+ height:100px;
+ margin:15px 0px;
+}
/* wSABNZBD */
#sabnzbdblock {
View
@@ -6,18 +6,33 @@
function widgetNowPlayingControls() {
echo <<< NOWPLAYINGCONTROLS
- <a class='controlbutton' onclick='cmdNowPlaying("PlayPause");' href='#'><img src='media/btnPlayPause.png' alt='Play/Pause'/></a>
+ <div id='nowplayingcontrols'>
+ <a class='controlbutton' onclick='cmdNowPlaying("PlayPause");' href='#'><img src='media/btnPlayPause.png' alt='Play/Pause'/></a>
<a class='controlbutton' onclick='cmdNowPlaying("Stop");' href='#'><img src='media/btnStop.png' alt='Stop'/></a>
+ <a class='controlbutton' onclick='cmdNowPlaying("ShowPlaylist");' href='#'>Show Playlist</a>
+ </div>
+ <div id='nowplayinglist'>
+ </div>
NOWPLAYINGCONTROLS;
}
function widgetNowPlayingHeader() {
echo <<< NOWPLAYINGHEADER
<script type="text/javascript" language="javascript">
<!--
function cmdNowPlaying(cmd) {
- var cmdPlayingRequest = new ajaxRequest();
- cmdPlayingRequest.open("GET", "widgets/wNowPlaying.php?ajax=c&command="+cmd, true);
- cmdPlayingRequest.send(null);
+ var cmdXbmcPlayingRequest = new ajaxRequest();
+ cmdXbmcPlayingRequest.open("GET", "widgets/wNowPlaying.php?ajax=c&command="+cmd, true);
+ cmdXbmcPlayingRequest.onreadystatechange = function() {
+ if (cmdXbmcPlayingRequest.readyState==4) {
+ if (cmdXbmcPlayingRequest.status==200 || window.location.href.indexOf("http")==-1) {
+ document.getElementById("nowplayinglist").innerHTML=cmdXbmcPlayingRequest.responseText;
+ } else {
+ alert("An error has occured making the request");
+ }
+ }
+ }
+
+ cmdXbmcPlayingRequest.send(null);
}
-->
</script>
@@ -147,53 +162,97 @@ function cmdNowPlaying(cmd) {
if (!empty($_GET['command'])) {
$command = $_GET["command"];
- /*
- // Commands
- PlayPause, Pauses or unpause playback
- Stop, Stops playback
- SkipPrevious, Skips to previous item on the playlist
- SkipNext, Skips to next item on the playlist
- BigSkipBackward,
- BigSkipForward,
- SmallSkipBackward,
- SmallSkipForward,
- Rewind, Rewind current playback
- Forward, Forward current playback
- */
-
-
- //get active players
- $request = '{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}';
- $results = jsoncall($request);
-
- //Video Player
- if (($results['result']['video']) == 1) {
- //get playlist items
- $player = "VideoPlayer";
- //Music Player
- } elseif (($results['result']['audio']) == 1) {
- //get playlist items
- $player = "AudioPlayer";
- } else {
- // Nothing Playing
- }
+ if ($command == "ShowPlaylist") {
+
+ $results = jsoncall('{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}');
+
+
+ if (($results['result']['video']) == 1) {
+ echo "\t\t<p>Not Yet Implemented</p>\n";
+
+ } elseif (($results['result']['audio']) == 1) {
+
+ $results = jsoncall('{"jsonrpc": "2.0", "method": "AudioPlaylist.GetItems", "params": { "fields": ["title", "album", "artist", "duration"] }, "id": 1}');
+
+
+ if (array_key_exists('items', $results['result'])) {
+ $items = $results['result']['items'];
+ $current = $results['result']['current'];
+
+ $songcount = count($results);
+ $i = 0;
- $request = '{"jsonrpc": "2.0", "method": "'.$player.'.'.$command.'", "id": 1}';
- $result = jsoncall($request);
-
- // debugging
- if($_GET["debug"] == "y") {
- echo "<br/>Call: <pre>";
- echo print_r($request,1);
- echo "</pre><br/>";
- echo "<br/>Result: <pre>";
- echo print_r($result,1);
- echo "</pre><br/>";
+ foreach ($items as $queueItem) {
+
+ if ($i > $current) {
+
+
+ $thumb = $queueItem['thumbnail'];
+ $artist = $queueItem['artist'];
+ $title = $queueItem['title'];
+ $album = $queueItem['album'];
+ if(strlen($thumb) > 0) {
+ echo "<div id='playlist-item-".$i."' class='playlist-item'>";
+ echo " <img src=".$xbmcimgpath.$thumb."></img>";
+ }
+ echo " <p>".$artist."</p>";
+ echo " <p>".$title."</p>";
+ echo " <p>".$album."</p></div>";
+ }
+ $i++;
+
+ }
+
+ }
+ }
+ } else {
+ /* XBMC Player Commands
+ PlayPause, Pauses or unpause playback
+ Stop, Stops playback
+ SkipPrevious, Skips to previous item on the playlist
+ SkipNext, Skips to next item on the playlist
+ BigSkipBackward,
+ BigSkipForward,
+ SmallSkipBackward,
+ SmallSkipForward,
+ Rewind, Rewind current playback
+ Forward, Forward current playback
+ */
+
+
+ //get active players
+ $request = '{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}';
+ $results = jsoncall($request);
+
+ //Video Player
+ if (($results['result']['video']) == 1) {
+ //get playlist items
+ $player = "VideoPlayer";
+ //Music Player
+ } elseif (($results['result']['audio']) == 1) {
+ //get playlist items
+ $player = "AudioPlayer";
+ } else {
+ // Nothing Playing
+ }
+
+ $request = '{"jsonrpc": "2.0", "method": "'.$player.'.'.$command.'", "id": 1}';
+ $result = jsoncall($request);
+
+ // debugging
+ if($_GET["debug"] == "y") {
+ echo "<br/>Call: <pre>";
+ echo print_r($request,1);
+ echo "</pre><br/>";
+ echo "<br/>Result: <pre>";
+ echo print_r($result,1);
+ echo "</pre><br/>";
+ }
}
} else {
echo "<br/>\n<p><strong>Invalid Request<strong></p>\n<p>Call: <pre>\n";
echo print_r($_GET,1);
echo "</pre>\n</p>\n";
}
}
-?>
+?>

0 comments on commit 98a5b7a

Please sign in to comment.