2011-08-21, 01:14
_Mikie_ Wrote:Personally instead of going through all the hassle of editing configs and ini's and because you don't know exactly what everything links to rather just hard code the values into the widget and then when you update your install just back up a copy of your layout and that widget. I haven't looked at the widget though so I don't know how much work it entails. I'll look at it later next week and maybe make a branch with it in so you can just download it from there with everything in place
Ok, job done. I think the longest part was figuring out that I had to change the front.css file too!
Otherwise, I only had to hardcode a specific json service uri in my widget.php as you suggested:
It was a bit tricky to find all the variables (local PHP variables, global PHP variables, and embedded javascript variables) I had to rename to <name2>.
$results = jsonmethodcall("VideoPlaylist.GetItems");
becomes
$results = jsonmethodcall("VideoPlaylist.GetItems", array(), 'http://antec.local:8080/jsonrpc');
$ cat front.css
Code:
/* wNOWPLAYING */
#wNowPlaying img, #wNowPlaying2 img {
float: left;
padding: 0 5px 5px 0;
max-height: 100px;
max-width: 100px;
}
#wNowPlaying div.progressbar, #wNowPlaying2 div.progressbar {
width: 100%;
height: 10px;
clear:both;
}
#wNowPlaying div.controls, #wNowPlaying2 div.controls {
margin-top:5px;
}
#wNowPlaying .playlist-item, #wNowPlaying2 .playlist-item2 {
display: block;
height:100px;
margin-top:15px;
}
#wNowPlaying #thumbblock img, #wNowPlaying2 #thumbblock2 img {
/* border: 1px solid #000; */
border: none;
}
$ diff wNowPlaying2.php wNowPlaying.php
Code:
2,13c2,13
< $wdgtNowPlayingAjax2 = array("type" => "ajax", "block" => "nowplayingwrapper2", "call" => "widgets/wNowPlaying2.php?ajax=w", "interval" => 1000);
< $wdgtNowPlayingControls2 = array("type" => "inline", "function" => "widgetNowPlayingControls2();", "headerfunction" => "widgetNowPlayingHeader2();");
< $wdgtNowPlaying2 = array("name" => "Now Playing2", "type" => "mixed", "parts" => array($wdgtNowPlayingAjax2, $wdgtNowPlayingControls2));
< $wIndex["wNowPlaying2"] = $wdgtNowPlaying2;
<
< function widgetNowPlayingControls2($baseurl = "") {
< echo "<div id=\"nowplaying-controls2\" class=\"controls\">\n";
< echo "\t".anchorControlButton2($baseurl, 'SkipPrevious', 'btnSkipBackward.png', 'Skip Back')."\n";
< echo "\t".anchorControlButton2($baseurl, 'PlayPause', 'btnPlayPause.png', 'Play/Pause')."\n";
< echo "\t".anchorControlButton2($baseurl, 'Stop', 'btnStop.png')."\n";
< echo "\t".anchorControlButton2($baseurl, 'SkipNext', 'btnSkipForward.png', 'Skip Next')."\n";
< echo "\t".anchorControlButton2($baseurl, 'ShowPlaylist', 'btnPlayList.png')."\n";
---
> $wdgtNowPlayingAjax = array("type" => "ajax", "block" => "nowplayingwrapper", "call" => "widgets/wNowPlaying.php?ajax=w", "interval" => 1000);
> $wdgtNowPlayingControls = array("type" => "inline", "function" => "widgetNowPlayingControls();", "headerfunction" => "widgetNowPlayingHeader();");
> $wdgtNowPlaying = array("name" => "Now Playing", "type" => "mixed", "parts" => array($wdgtNowPlayingAjax, $wdgtNowPlayingControls));
> $wIndex["wNowPlaying"] = $wdgtNowPlaying;
>
> function widgetNowPlayingControls($baseurl = "") {
> echo "<div id=\"nowplaying-controls\" class=\"controls\">\n";
> echo "\t".anchorControlButton($baseurl, 'SkipPrevious', 'btnSkipBackward.png', 'Skip Back')."\n";
> echo "\t".anchorControlButton($baseurl, 'PlayPause', 'btnPlayPause.png', 'Play/Pause')."\n";
> echo "\t".anchorControlButton($baseurl, 'Stop', 'btnStop.png')."\n";
> echo "\t".anchorControlButton($baseurl, 'SkipNext', 'btnSkipForward.png', 'Skip Next')."\n";
> echo "\t".anchorControlButton($baseurl, 'ShowPlaylist', 'btnPlayList.png')."\n";
16c16
< echo "<div id=\"nowplaying-list2\"></div>\n";
---
> echo "<div id=\"nowplaying-list\"></div>\n";
18c18
< function widgetNowPlayingHeader2() {
---
> function widgetNowPlayingHeader() {
22,28c22,28
< function cmdNowPlaying2(cmd) {
< var cmdXbmcPlayingRequest2 = new ajaxRequest();
< cmdXbmcPlayingRequest2.open("GET", "widgets/wNowPlaying2.php?ajax=c&command="+cmd, true);
< cmdXbmcPlayingRequest2.onreadystatechange = function() {
< if (cmdXbmcPlayingRequest2.readyState==4) {
< if (cmdXbmcPlayingRequest2.status==200 || window.location.href.indexOf("http")==-1) {
< document.getElementById("nowplaying-list2").innerHTML=cmdXbmcPlayingRequest2.responseText;
---
> function cmdNowPlaying(cmd) {
> 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("nowplaying-list").innerHTML=cmdXbmcPlayingRequest.responseText;
35c35
< cmdXbmcPlayingRequest2.send(null);
---
> cmdXbmcPlayingRequest.send(null);
44c44
< function anchorControlButton2($baseurl, $cmd, $img = "", $label = "") {
---
> function anchorControlButton($baseurl, $cmd, $img = "", $label = "") {
55c55
< $anchorlink = "onclick=\"cmdNowPlaying2('".$cmd."');\" href=\"#\"";
---
> $anchorlink = "onclick=\"cmdNowPlaying('".$cmd."');\" href=\"#\"";
60,61c60,61
< function displayNowPlaying2($baseurl = "") {
< $xbmcimgpath = "http://antec.local:8080/vfs/";
---
> function displayNowPlaying($baseurl = "") {
> global $xbmcimgpath;
64c64
< processCommand2($_GET['cmd']);
---
> processCommand($_GET['cmd']);
67c67
< echo "<div id=\"nowplaying2\">\n";
---
> echo "<div id=\"nowplaying\">\n";
70c70
< $results = jsonmethodcall("Player.GetActivePlayers", array(), 'http://antec.local:8080/jsonrpc');
---
> $results = jsonmethodcall("Player.GetActivePlayers");
74c74
< $jsonVersion = jsonmethodcall("JSONRPC.Version", array(), 'http://antec.local:8080/jsonrpc'); //pull the JSON version # from XBMC
---
> $jsonVersion = jsonmethodcall("JSONRPC.Version"); //pull the JSON version # from XBMC
78c78
< $results = jsonmethodcall("VideoPlaylist.GetItems", array(), 'http://antec.local:8080/jsonrpc'); //Pull the current "playlist"
---
> $results = jsonmethodcall("VideoPlaylist.GetItems"); //Pull the current "playlist"
152c152
< $results = jsonmethodcall("VideoPlaylistV3.GetItems", array(), 'http://antec.local:8080/jsonrpc'); //Pull the current "playlist"
---
> $results = jsonmethodcall("VideoPlaylistV3.GetItems"); //Pull the current "playlist"
223c223
< echo "\t<div id=\"thumbblock2\" class=\"thumbblockvideo\">\n";
---
> echo "\t<div id=\"thumbblock\" class=\"thumbblockvideo\">\n";
234c234
< echo "\t\t<p>".$line3."</p>\n";
---
> echo "\t\t<p>".$line3."</p>\n"; // Plot Summary
236c236
< $results = jsonmethodcall("VideoPlayer.GetTime", array(), 'http://antec.local:8080/jsonrpc');
---
> $results = jsonmethodcall("VideoPlayer.GetTime");
262c262
< $results = jsonmethodcall("VideoPlayer.GetPercentage", array(), 'http://antec.local:8080/jsonrpc');
---
> $results = jsonmethodcall("VideoPlayer.GetPercentage");
267c267
< widgetNowPlayingControls2($baseurl);
---
> widgetNowPlayingControls($baseurl);
271c271
< $results = jsonmethodcall("AudioPlaylist.GetItems", array(), 'http://antec.local:8080/jsonrpc');
---
> $results = jsonmethodcall("AudioPlaylist.GetItems");
280c280
< echo "\t<div id=\"thumbblock2\" class=\"thumbblockaudio\">\n";
---
> echo "\t<div id=\"thumbblock\" class=\"thumbblockaudio\">\n";
295c295
< $results = jsonmethodcall("AudioPlayer.GetTime", array(), 'http://antec.local:8080/jsonrpc');
---
> $results = jsonmethodcall("AudioPlayer.GetTime");
305c305
< $results = jsonmethodcall("AudioPlayer.GetPercentage", array(), 'http://antec.local:8080/jsonrpc');
---
> $results = jsonmethodcall("AudioPlayer.GetPercentage");
310c310
< widgetNowPlayingControls2($baseurl);
---
> widgetNowPlayingControls($baseurl);
317,318c317,318
< function processCommand2($command) {
< $xbmcimgpath = "http://antec.local:8080/vfs/";
---
> function processCommand($command) {
> global $xbmcimgpath;
322c322
< $results = jsonmethodcall("Player.GetActivePlayers", array(), 'http://antec.local:8080/jsonrpc');
---
> $results = jsonmethodcall("Player.GetActivePlayers");
326c326
< $results = jsonmethodcall("AudioPlaylist.GetItems", array(), 'http://antec.local:8080/jsonrpc');
---
> $results = jsonmethodcall("AudioPlaylist.GetItems");
342c342
< echo "<div id=\"playlist-item2-".$i."\" class=\"playlist-item\">\n";
---
> echo "<div id=\"playlist-item-".$i."\" class=\"playlist-item\">\n";
372c372
< $results = jsonmethodcall("Player.GetActivePlayers", array(), 'http://antec.local:8080/jsonrpc');
---
> $results = jsonmethodcall("Player.GetActivePlayers");
385c385
< $results = jsonmethodcall($player.'.'.$command, array(), 'http://antec.local:8080/jsonrpc');
---
> $results = jsonmethodcall($player.'.'.$command);
403c403
< displayNowPlaying2();
---
> displayNowPlaying();
412c412
< processCommand2($command);
---
> processCommand($command);
432c432
< displayNowPlaying2();
---
> displayNowPlaying();
438c438
< displayNowPlaying2();
---
> displayNowPlaying();