|
From: <mr...@us...> - 2012-01-28 21:33:16
|
Revision: 669
http://openautomation.svn.sourceforge.net/openautomation/?rev=669&view=rev
Author: mrremy
Date: 2012-01-28 21:33:09 +0000 (Sat, 28 Jan 2012)
Log Message:
-----------
initial version of upnpcontroller
Modified Paths:
--------------
CometVisu/trunk/visu/visu_config.xml
Added Paths:
-----------
CometVisu/trunk/visu/plugins/upnpcontroller/
CometVisu/trunk/visu/plugins/upnpcontroller/mute.php
CometVisu/trunk/visu/plugins/upnpcontroller/next.php
CometVisu/trunk/visu/plugins/upnpcontroller/pause.php
CometVisu/trunk/visu/plugins/upnpcontroller/play.php
CometVisu/trunk/visu/plugins/upnpcontroller/prev.php
CometVisu/trunk/visu/plugins/upnpcontroller/status.php
CometVisu/trunk/visu/plugins/upnpcontroller/structure_plugin.js
CometVisu/trunk/visu/plugins/upnpcontroller/upnpcontroller.css
CometVisu/trunk/visu/plugins/upnpcontroller/upnpctrl_util.php
CometVisu/trunk/visu/plugins/upnpcontroller/volume.php
Added: CometVisu/trunk/visu/plugins/upnpcontroller/mute.php
===================================================================
--- CometVisu/trunk/visu/plugins/upnpcontroller/mute.php (rev 0)
+++ CometVisu/trunk/visu/plugins/upnpcontroller/mute.php 2012-01-28 21:33:09 UTC (rev 669)
@@ -0,0 +1,50 @@
+<?php
+/* mute.php (c) 2012 by Mark K. [mr dot remy at gmx dot de]
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+*/
+
+require 'upnpctrl_util.php';
+
+header("content-type: text/html");
+//header("content-type: text/json");
+$mute = $_GET['mute'];
+
+$cmd_setmute='POST /MediaRenderer/RenderingControl/Control HTTP/1.1
+CONNECTION: close
+HOST: '.$address.':1400
+CONTENT-LENGTH: 314
+CONTENT-TYPE: text/xml; charset="utf-8"
+SOAPACTION: "urn:schemas-upnp-org:service:RenderingControl:1#SetMute"
+
+<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetMute xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><Channel>Master</Channel><DesiredMute>'.$mute.'</DesiredMute></u:SetMute></s:Body></s:Envelope>';
+
+$actionResponse = sendUpnpAction($cmd_setmute, $address, $port);
+
+//echo "actionResponse xml: ";
+//print_r($actionResponse);
+//echo "</br>'";
+
+$xmlParser = xml_parser_create("UTF-8");
+xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, "UTF-8");
+xml_parse_into_struct($xmlParser, $actionResponse, $actionResponseArray, $index);
+xml_parser_free($xmlParser);
+
+//print_r($actionResponseArray);
+//print_r($index);
+
+print_r("{\"actionstatus\" : 'OK'}");
+
+?>
\ No newline at end of file
Added: CometVisu/trunk/visu/plugins/upnpcontroller/next.php
===================================================================
--- CometVisu/trunk/visu/plugins/upnpcontroller/next.php (rev 0)
+++ CometVisu/trunk/visu/plugins/upnpcontroller/next.php 2012-01-28 21:33:09 UTC (rev 669)
@@ -0,0 +1,49 @@
+<?php
+/* next.php (c) 2012 by Mark K. [mr dot remy at gmx dot de]
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+*/
+
+require 'upnpctrl_util.php';
+
+//header("content-type: text/html");
+header("content-type: text/json");
+
+$cmd_next='POST /MediaRenderer/AVTransport/Control HTTP/1.1
+CONNECTION: close
+HOST: '.$address.':1400
+CONTENT-LENGTH: 250
+CONTENT-TYPE: text/xml; charset="utf-8"
+SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Next"
+
+<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:Next xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID></u:Next></s:Body></s:Envelope>';
+
+$actionResponse = sendUpnpAction($cmd_next, $address, $port);
+
+//echo "actionResponse xml: ";
+//print_r($actionResponse);
+//echo "</br>'";
+
+$xmlParser = xml_parser_create("UTF-8");
+xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, "UTF-8");
+xml_parse_into_struct($xmlParser, $actionResponse, $actionResponseArray, $index);
+xml_parser_free($xmlParser);
+
+//print_r($actionResponseArray);
+//print_r($index);
+
+print_r("{\"actionstatus\" : 'OK'}");
+
+?>
\ No newline at end of file
Added: CometVisu/trunk/visu/plugins/upnpcontroller/pause.php
===================================================================
--- CometVisu/trunk/visu/plugins/upnpcontroller/pause.php (rev 0)
+++ CometVisu/trunk/visu/plugins/upnpcontroller/pause.php 2012-01-28 21:33:09 UTC (rev 669)
@@ -0,0 +1,49 @@
+<?php
+/* pause.php (c) 2012 by Mark K. [mr dot remy at gmx dot de]
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+*/
+
+require 'upnpctrl_util.php';
+
+//header("content-type: text/html");
+header("content-type: text/json");
+
+$cmd_pause='POST /MediaRenderer/AVTransport/Control HTTP/1.1
+CONNECTION: close
+HOST: '.$address.':1400
+CONTENT-LENGTH: 252
+CONTENT-TYPE: text/xml; charset="utf-8"
+SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Pause"
+
+<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:Pause xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID></u:Pause></s:Body></s:Envelope>';
+
+$actionResponse = sendUpnpAction($cmd_pause, $address, $port);
+
+//echo "actionResponse xml: ";
+//print_r($actionResponse);
+//echo "</br>'";
+
+$xmlParser = xml_parser_create("UTF-8");
+xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, "UTF-8");
+xml_parse_into_struct($xmlParser, $actionResponse, $actionResponseArray, $index);
+xml_parser_free($xmlParser);
+
+//print_r($actionResponseArray);
+//print_r($index);
+
+print_r("{\"actionstatus\" : 'OK'}");
+
+?>
\ No newline at end of file
Added: CometVisu/trunk/visu/plugins/upnpcontroller/play.php
===================================================================
--- CometVisu/trunk/visu/plugins/upnpcontroller/play.php (rev 0)
+++ CometVisu/trunk/visu/plugins/upnpcontroller/play.php 2012-01-28 21:33:09 UTC (rev 669)
@@ -0,0 +1,49 @@
+<?php
+/* play.php (c) 2012 by Mark K. [mr dot remy at gmx dot de]
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+*/
+
+require 'upnpctrl_util.php';
+
+//header("content-type: text/html");
+header("content-type: text/json");
+
+$cmd_play='POST /MediaRenderer/AVTransport/Control HTTP/1.1
+CONNECTION: close
+HOST: '.$address.':1400
+CONTENT-LENGTH: 266
+CONTENT-TYPE: text/xml; charset="utf-8"
+SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Play"
+
+<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:Play xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><Speed>1</Speed></u:Play></s:Body></s:Envelope>';
+
+$actionResponse = sendUpnpAction($cmd_play, $address, $port);
+
+//echo "actionResponse xml: ";
+//print_r($actionResponse);
+//echo "</br>'";
+
+$xmlParser = xml_parser_create("UTF-8");
+xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, "UTF-8");
+xml_parse_into_struct($xmlParser, $actionResponse, $actionResponseArray, $index);
+xml_parser_free($xmlParser);
+
+//print_r($actionResponseArray);
+//print_r($index);
+
+print_r("{\"actionstatus\" : 'OK'}");
+
+?>
\ No newline at end of file
Added: CometVisu/trunk/visu/plugins/upnpcontroller/prev.php
===================================================================
--- CometVisu/trunk/visu/plugins/upnpcontroller/prev.php (rev 0)
+++ CometVisu/trunk/visu/plugins/upnpcontroller/prev.php 2012-01-28 21:33:09 UTC (rev 669)
@@ -0,0 +1,49 @@
+<?php
+/* prev.php (c) 2012 by Mark K. [mr dot remy at gmx dot de]
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+*/
+
+require 'upnpctrl_util.php';
+
+//header("content-type: text/html");
+header("content-type: text/json");
+
+$cmd_prev = 'POST /MediaRenderer/AVTransport/Control HTTP/1.1
+CONNECTION: close
+HOST: '.$address.':1400
+CONTENT-LENGTH: 258
+CONTENT-TYPE: text/xml; charset="utf-8"
+SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Previous"
+
+<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:Previous xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID></u:Previous></s:Body></s:Envelope>';
+
+$actionResponse = sendUpnpAction($cmd_prev, $address, $port);
+
+//echo "actionResponse xml: ";
+//print_r($actionResponse);
+//echo "</br>'";
+
+$xmlParser = xml_parser_create("UTF-8");
+xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, "UTF-8");
+xml_parse_into_struct($xmlParser, $actionResponse, $actionResponseArray, $index);
+xml_parser_free($xmlParser);
+
+//print_r($actionResponseArray);
+//print_r($index);
+
+print_r("{\"actionstatus\" : 'OK'}");
+
+?>
\ No newline at end of file
Added: CometVisu/trunk/visu/plugins/upnpcontroller/status.php
===================================================================
--- CometVisu/trunk/visu/plugins/upnpcontroller/status.php (rev 0)
+++ CometVisu/trunk/visu/plugins/upnpcontroller/status.php 2012-01-28 21:33:09 UTC (rev 669)
@@ -0,0 +1,144 @@
+<?php
+/* status.php (c) 2012 by Mark K. [mr dot remy at gmx dot de]
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+*/
+
+require 'upnpctrl_util.php';
+
+//header("content-type: text/html");
+header("content-type: text/json");
+
+$cmd_getvolume='POST /MediaRenderer/RenderingControl/Control HTTP/1.1
+CONNECTION: close
+HOST: '.$address.':1400
+CONTENT-LENGTH: 296
+CONTENT-TYPE: text/xml; charset="utf-8"
+SOAPACTION: "urn:schemas-upnp-org:service:RenderingControl:1#GetVolume"
+
+<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><ns0:GetVolume xmlns:ns0="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><Channel>Master</Channel></ns0:GetVolume></s:Body></s:Envelope>';
+
+$cmd_getmute='POST /MediaRenderer/RenderingControl/Control HTTP/1.1
+CONNECTION: close
+HOST: '.$address.':1400
+CONTENT-LENGTH: 288
+CONTENT-TYPE: text/xml; charset="utf-8"
+SOAPACTION: "urn:schemas-upnp-org:service:RenderingControl:1#GetMute"
+
+<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetMute xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><Channel>Master</Channel></ns0:GetMute></s:Body></s:Envelope>';
+
+$cmd_getpositioninfo='POST /MediaRenderer/AVTransport/Control HTTP/1.1
+CONNECTION: close
+HOST: '.$address.':1400
+CONTENT-LENGTH: 299
+CONTENT-TYPE: text/xml; charset="utf-8"
+SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#GetPositionInfo"
+
+<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetPositionInfo xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><Channel>Master</Channel></ns0:GetPositionInfo></s:Body></s:Envelope>';
+
+$cmd_gettransportinfo='POST /MediaRenderer/AVTransport/Control HTTP/1.1
+CONNECTION: close
+HOST: '.$address.':1400
+CONTENT-LENGTH: 274
+CONTENT-TYPE: text/xml; charset="utf-8"
+SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#GetTransportInfo"
+
+<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetTransportInfo xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID></u:GetTransportInfo></s:Body></s:Envelope>';
+
+
+ $actionResponse = sendUpnpAction($cmd_getvolume, $address, $port);
+
+ //echo "actionResponse xml: ";
+ //print_r($actionResponse);
+ //echo "</br>'";
+
+ $xmlParser = xml_parser_create("UTF-8");
+ xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, "UTF-8");
+ xml_parse_into_struct($xmlParser, $actionResponse, $actionResponseArray, $index);
+ xml_parser_free($xmlParser);
+
+ //print_r($actionResponseArray);
+ //print_r($index);
+
+ $volume = getValueOfResponse($actionResponseArray, "CURRENTVOLUME");
+
+ $actionResponse = sendUpnpAction($cmd_getmute, $address, $port);
+ $xmlParser = xml_parser_create("UTF-8");
+ xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, "UTF-8");
+ xml_parse_into_struct($xmlParser, $actionResponse, $actionResponseArray, $index);
+ xml_parser_free($xmlParser);
+
+ //print_r($actionResponseArray);
+
+ $muteState = getValueOfResponse($actionResponseArray, "CURRENTMUTE");
+
+ $actionResponse = sendUpnpAction($cmd_gettransportinfo, $address, $port);
+ $xmlParser = xml_parser_create("UTF-8");
+ xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, "UTF-8");
+ xml_parse_into_struct($xmlParser, $actionResponse, $actionResponseArray, $index);
+ xml_parser_free($xmlParser);
+
+// print_r($actionResponseArray);
+
+ $transportStateResponse = getValueOfResponse($actionResponseArray, "CURRENTTRANSPORTSTATE");
+
+ if($transportStateResponse == "PAUSED_PLAYBACK"){
+ $transportState = 'Pause';
+ }else if($transportStateResponse == "PLAYING"){
+ $transportState = 'Play';
+ }else if($transportStateResponse == "STOPPED"){
+ $transportState = 'Stop';
+ }else{
+ $transportState = 'unknown';
+ }
+
+ $actionResponse = sendUpnpAction($cmd_getpositioninfo, $address, $port);
+ $xmlParser = xml_parser_create("UTF-8");
+ xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, "UTF-8");
+ xml_parse_into_struct($xmlParser, $actionResponse, $actionResponseArray, $index);
+ xml_parser_free($xmlParser);
+
+// print_r($actionResponseArray);
+
+ $reltimeResponse = getValueOfResponse($actionResponseArray, "RELTIME");
+ $durationResponse = getValueOfResponse($actionResponseArray, "TRACKDURATION");
+ $trackMetaDataResponse = getValueOfResponse($actionResponseArray, "TRACKMETADATA");
+
+// print_r($trackMetaDataResponse);
+
+ $xmlParser = xml_parser_create("UTF-8");
+ xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, "UTF-8");
+ xml_parse_into_struct($xmlParser, $trackMetaDataResponse, $actionResponseArray, $index);
+ xml_parser_free($xmlParser);
+
+// print_r($actionResponseArray);
+
+ $title = getValueOfResponse($actionResponseArray, "TITLE");
+ $artist = getValueOfResponse($actionResponseArray, "ALBUMARTIST");
+ $album = getValueOfResponse($actionResponseArray, "ALBUM");
+
+ //
+ // create JSON response
+ //
+ print_r("{\"volume\" : " . $volume . ", \"muteState\" : " . $muteState
+ . ", \"transportState\" : \"" . $transportState
+ . "\" , \"reltimeResponse\" : \"" . $reltimeResponse
+ . "\" , \"durationResponse\" : \"" . $durationResponse
+ . "\" , \"title\" : \"" . $title
+ . "\" , \"artist\" : \"" . $artist
+ . "\" , \"album\" : \"" . $album
+ . "\" , \"error_msg\" : \"" . $error_msg . "\"}");
+
+?>
\ No newline at end of file
Added: CometVisu/trunk/visu/plugins/upnpcontroller/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/upnpcontroller/structure_plugin.js (rev 0)
+++ CometVisu/trunk/visu/plugins/upnpcontroller/structure_plugin.js 2012-01-28 21:33:09 UTC (rev 669)
@@ -0,0 +1,299 @@
+/* structure_plugin.js (c) 2012 by Mark K. [mr dot remy at gmx dot de]
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+*/
+
+
+$( 'head' ).append( '<link rel="stylesheet" href="plugins/upnpcontroller/upnpcontroller.css" type="text/css" />' );
+
+var upnpcontroller_uid;
+
+
+VisuDesign_Custom.prototype.addCreator("upnpcontroller", {
+ create: function( page, path ) {
+ var $p = $(page);
+
+ function uniqid() {
+ var newDate = new Date;
+ return newDate.getTime();
+ }
+
+ var id = "upnpcontroller_" + uniqid();
+ upnpcontroller_uid = id;
+
+ var ret_val = $('<div class="widget" />');
+ ret_val.addClass( 'upnpcontroller' );
+ var label = '<div class="label">' + $p.attr("label") + '</div>';
+ var actor = $("<div class=\"actor\"><div class=\"upnpcontroller\" id=\"" + id + "\">loading</div></div>");
+ var upnpcontroller = $("#" + id, actor);
+
+ controller = $("<div></div>");
+
+ controller.append( "<div id='" + id + "_title' class='upnplabelgroup'><div class='upnplabel'>Title</div><div class='value'>-</div></div>");
+ controller.append( "<div id='" + id + "_artist' class='upnplabelgroup'><div class='upnplabel'>Artist</div><div class='value'>-</div></div>");
+ controller.append( "<div id='" + id + "_album' class='upnplabelgroup'><div class='upnplabel'>Album</div><div class='value'>-</div></div>");
+ controller.append( "<div id='" + id + "_time' class='upnplabelgroup'><div class='upnplabel'></div><div class='value'>-</div></div>");
+ controller.append( "<div style='float: left;'><div id='" + id + "_volumedown' class='actor center switchUnpressed'><div class='value'>-</div></div>"
+ + "<div id='" + id + "_volume' class='actor center switchInvisible' style='text-align: center;'><div class='value'>20</div></div>"
+ + "<div id='" + id + "_volumeup' class='actor center switchUnpressed'><div class='value'>+</div></div></div>" );
+ controller.append( "<div style='float: left;'><div id='" + id + "_playButton' class='actor switchUnpressed center'><div class='value'>-</div></div>"
+ + "<div id='" + id + "_muteButton' class='actor switchUnpressed center'><div class='value'>-</div></div>" );
+ controller.append( "<div style='float: left;'><div id='" + id + "_prev' class='actor switchUnpressed center'><div class='value'>prev</div></div>"
+ + "<div id='" + id + "_next' class='actor switchUnpressed center'><div class='value'>next</div></div></div>" );
+
+ upnpcontroller.html(controller);
+
+ ret_val.append(label).append(actor);
+// console.log("loaded plugin upnpcontroller");
+
+ upnpcontroller.data("id", id);
+ upnpcontroller.data("eventsRegistered", 0);
+ upnpcontroller.data("label", $p.attr("label"));
+ upnpcontroller.data("refresh", $p.attr("refresh"));
+ upnpcontroller.data("player_ip", $p.attr("player_ip_addr"));
+ upnpcontroller.data("debug", $p.attr("debug"));
+
+ refreshUpnpcontroller(upnpcontroller, {}, false);
+
+ return ret_val;
+ },
+ attributes: {
+ label: {type: "string", required: true},
+ player_ip_addr: {type: "string", required: true},
+ refresh: {type: "numeric", required: true},
+ debug: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ },
+ content: false
+});
+
+
+function refreshUpnpcontroller(upnpcontroller, data, oneTimeCall) {
+ var upnpcontroller = $(upnpcontroller);
+
+ var playerIp = upnpcontroller.data("player_ip");
+ var id = upnpcontroller.data("id");
+ var debug = upnpcontroller.data("debug");
+ var eventsRegistered = upnpcontroller.data("eventsRegistered");
+ var label = upnpcontroller.data("label");
+ var refresh = upnpcontroller.data("refresh");
+
+ console.log("debug: " + debug);
+
+ if(debug == 'true'){
+ console.log("playerIp: " + playerIp);
+ }
+
+ function updateContoller( volume, mute, playMode, title, reltime, duration, artist, album){
+
+ if(mute == 0){
+ $('#' + upnpcontroller_uid + '_muteButton').removeClass('switchPressed');
+ $('#' + upnpcontroller_uid + '_muteButton').addClass('switchUnpressed');
+ }else{
+ $('#' + upnpcontroller_uid + '_muteButton').removeClass('switchUnpressed');
+ $('#' + upnpcontroller_uid + '_muteButton').addClass('switchPressed');
+ }
+
+ if(playMode == 'Play'){
+ $('#' + upnpcontroller_uid + '_playButton').removeClass('switchUnpressed');
+ $('#' + upnpcontroller_uid + '_playButton').addClass('switchPressed');
+ }else{
+ $('#' + upnpcontroller_uid + '_playButton').removeClass('switchPressed');
+ $('#' + upnpcontroller_uid + '_playButton').addClass('switchUnpressed');
+ }
+
+ $('#' + id + '_muteButton div.value').text(mute);
+ $('#' + id + '_playButton div.value').text(playMode);
+ $('#' + id + '_volume div.value').text(volume);
+ $('#' + id + '_title div.value').text(title);
+ $('#' + id + '_artist div.value').text(artist);
+ $('#' + id + '_album div.value').text(album);
+ $('#' + id + '_time div.value').text(reltime + ' of ' + duration);
+
+ }
+
+ $.ajax({
+ type: "GET",
+ datatype: "JSON",
+ url: "plugins/upnpcontroller/status.php?player_ip_addr=" + playerIp,
+ success: function(data){
+
+ if(debug == 'true'){
+ console.log("volume : " + data.volume);
+ console.log("reltime : " + data.reltimeResponse);
+ console.log("durationResponse: " + data.durationResponse);
+ console.log("title : " + data.title);
+ }
+
+ updateContoller(data.volume, data.muteState, data.transportState, data.title
+ , data.reltimeResponse, data.durationResponse, data.artist, data.album);
+ }
+ });
+
+ if(eventsRegistered < 2) {
+// console.log("eventsRegistered: " + eventsRegistered);
+
+ $('#' + upnpcontroller_uid + '_muteButton').bind('click', toggleMute);
+ $('#' + upnpcontroller_uid + '_playButton').bind('click', togglePlay);
+ $('#' + upnpcontroller_uid + '_next').bind('click', callNext);
+ $('#' + upnpcontroller_uid + '_prev').bind('click', callPrev);
+ $('#' + upnpcontroller_uid + '_volumedown').bind('click', callvolumedown);
+ $('#' + upnpcontroller_uid + '_volumeup').bind('click', callvolumeup);
+
+ upnpcontroller.data("eventsRegistered", eventsRegistered + 1);
+ }
+
+ //refresh regularly
+ if (typeof (refresh) != "undefined" && refresh && oneTimeCall == false) {
+ // reload regularly
+ window.setTimeout(function(upnpcontroller, data) {
+ refreshUpnpcontroller(upnpcontroller, data, false)
+ }, refresh * 1000, upnpcontroller, data);
+ }
+
+ return false;
+}
+
+function callvolumedown() {
+ console.log("click callvolumedown");
+ var upnpctrl = $("#" + upnpcontroller_uid);
+ var playerIp = upnpctrl.data("player_ip");
+ var currentVolume = $('#' + upnpcontroller_uid + '_volume div.value').text();
+
+ console.log("currentVolume: " + currentVolume);
+
+ var volume = Number(currentVolume) - 5;
+
+ $.ajax({
+ type: "GET",
+ datatype: "JSON",
+ url: "plugins/upnpcontroller/volume.php?player_ip_addr=" + playerIp + "&volume=" + volume,
+ success: function(data){
+ console.log("data: " + data);
+ }
+ });
+}
+
+function callvolumeup() {
+ console.log("click callvolumeup");
+ var upnpctrl = $("#" + upnpcontroller_uid);
+ var playerIp = upnpctrl.data("player_ip");
+ var currentVolume = $('#' + upnpcontroller_uid + '_volume div.value').text();
+
+ console.log("currentVolume: " + currentVolume);
+
+ var volume = Number(currentVolume) + 5;
+
+ $.ajax({
+ type: "GET",
+ datatype: "JSON",
+ url: "plugins/upnpcontroller/volume.php?player_ip_addr=" + playerIp + "&volume=" + volume,
+ success: function(data){
+ console.log("data: " + data);
+ }
+ });
+}
+
+function callNext() {
+ console.log("click next");
+ var upnpctrl = $("#" + upnpcontroller_uid);
+ var playerIp = upnpctrl.data("player_ip");
+
+ $.ajax({
+ type: "GET",
+ datatype: "JSON",
+ url: "plugins/upnpcontroller/next.php?player_ip_addr=" + playerIp,
+ success: function(data){
+ console.log("data: " + data);
+ }
+ });
+}
+
+function callPrev() {
+ console.log("click prev");
+ var upnpctrl = $("#" + upnpcontroller_uid);
+ var playerIp = upnpctrl.data("player_ip");
+
+ $.ajax({
+ type: "GET",
+ datatype: "JSON",
+ url: "plugins/upnpcontroller/prev.php?player_ip_addr=" + playerIp,
+ success: function(data){
+ console.log("data: " + data);
+ }
+ });
+}
+
+function toggleMute() {
+ console.log("click mute");
+ var upnpctrl = $("#" + upnpcontroller_uid);
+ var playerIp = upnpctrl.data("player_ip");
+
+ var muteValue = $('#' + upnpcontroller_uid + '_muteButton div.value').text();
+
+ console.log("current muteValue: " + muteValue);
+
+ if(muteValue == 0){
+ muteValue = 1;
+ $('#' + upnpcontroller_uid + '_muteButton').removeClass('switchUnpressed');
+ $('#' + upnpcontroller_uid + '_muteButton').addClass('switchPressed');
+ }else{
+ muteValue = 0;
+ $('#' + upnpcontroller_uid + '_muteButton').removeClass('switchPressed');
+ $('#' + upnpcontroller_uid + '_muteButton').addClass('switchUnpressed');
+ }
+
+ $.ajax({
+ type: "GET",
+ datatype: "JSON",
+ url: "plugins/upnpcontroller/mute.php?mute=" + muteValue + "&player_ip_addr=" + playerIp,
+ success: function(data){
+ console.log("data: " + data);
+ }
+ });
+
+ refreshUpnpcontroller(upnpctrl, {}, true);
+}
+
+function togglePlay() {
+ console.log("click play");
+ var upnpctrl = $("#" + upnpcontroller_uid);
+ var playerIp = upnpctrl.data("player_ip");
+ var playValue = $('#' + upnpcontroller_uid + '_playButton div.value').text();
+ var cmd;
+
+ console.log("current playValue: " + playValue);
+
+ if(playValue == 'Play'){
+ cmd = 'pause';
+ $('#' + upnpcontroller_uid + '_playButton').removeClass('switchUnpressed');
+ $('#' + upnpcontroller_uid + '_playButton').addClass('');
+ }else{
+ cmd = 'play';
+ $('#' + upnpcontroller_uid + '_playButton').removeClass('switchPressed');
+ $('#' + upnpcontroller_uid + '_playButton').addClass('switchUnpressed');
+ }
+
+ $.ajax({
+ type: "GET",
+ datatype: "JSON",
+ url: "plugins/upnpcontroller/" + cmd + ".php?player_ip_addr=" + playerIp,
+ success: function(data){
+ console.log("data: " + data);
+ }
+ });
+
+ refreshUpnpcontroller(upnpctrl, {}, true);
+}
+
Added: CometVisu/trunk/visu/plugins/upnpcontroller/upnpcontroller.css
===================================================================
--- CometVisu/trunk/visu/plugins/upnpcontroller/upnpcontroller.css (rev 0)
+++ CometVisu/trunk/visu/plugins/upnpcontroller/upnpcontroller.css 2012-01-28 21:33:09 UTC (rev 669)
@@ -0,0 +1,40 @@
+.upnpController {
+/* overflow: auto; */
+}
+
+.upnpController div.name {
+ font-weight: bold;
+ height: 24px;
+ padding: 4px 4px 4px 4px;
+}
+
+.upnpControllerList {
+ margin: 0;
+ padding: 0;
+ position: relative;
+}
+
+.upnpControllerList li {
+ background-color:#eeeeee;
+ display: inline;
+ list-style: none outside none;
+ padding-left: 2px;
+ padding-right: 2px;
+ margin-bottom: 2px;
+ position: relative;
+}
+
+.upnplabelgroup {
+ float: left;
+ padding-left: 1em;
+ text-align: left;
+ width: 100%;
+ line-height: 2em;
+}
+
+.upnplabel {
+ text-align: left;
+ float: left;
+ width: 14%;
+ line-height: 2em;
+}
Added: CometVisu/trunk/visu/plugins/upnpcontroller/upnpctrl_util.php
===================================================================
--- CometVisu/trunk/visu/plugins/upnpcontroller/upnpctrl_util.php (rev 0)
+++ CometVisu/trunk/visu/plugins/upnpcontroller/upnpctrl_util.php 2012-01-28 21:33:09 UTC (rev 669)
@@ -0,0 +1,116 @@
+<?php
+/* upnpctrl_util.php (c) 2012 by Mark K. [mr dot remy at gmx dot de]
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+*/
+
+$address = $_GET['player_ip_addr'];
+$port = 1400;
+$error_msg;
+
+
+function handleError($errno, $errstr, $errfile, $errline)
+{
+ switch ($errno) {
+
+ case E_USER_ERROR:
+ $error_msg = "Error [" . $errno . "] " . $errstr;
+ break;
+
+ case E_USER_WARNING:
+ $error_msg = "WARNING [" . $errno . "] " . $errstr;
+ break;
+
+ case E_USER_NOTICE:
+ $error_msg = "NOTICE [" . $errno . "] " . $errstr;
+ break;
+
+ default:
+ $error_msg = "Unknown error [" . $errno . "] " . $errstr;
+ break;
+ }
+
+ return true;
+}
+
+set_error_handler('handleError');
+
+
+ function sendUpnpAction($content, $address, $port)
+ {
+ $plainActionResponse = "";
+ $recieveBuffer = "";
+
+ try {
+ $fp = fsockopen($address, $port, $errno, $errstr, 10);
+ }
+ catch (Exception $e)
+ {
+ if(empty($error_msg)){
+ $error_msg = "Error on opening the socket " . $address . ":" . $port;
+ }
+
+ return $array[0];
+ }
+
+
+ if (!$fp){
+ if(empty($error_msg)){
+ $error_msg = "Error on opening the socket " . $address . ":" . $port;
+ }
+
+ return $array[0];
+ }
+
+ fputs ($fp, $content);
+
+ while (!feof($fp)) {
+ $recieveBuffer = fgets($fp, 256);
+ $plainActionResponse .= $recieveBuffer;
+ }
+
+ fclose($fp);
+
+ $array = preg_split("/\n/", $plainActionResponse);
+
+ //debug trace
+// print_r($array);
+
+ if(strpos($array[0], "200 OK") === false){
+ if(empty($error_msg)){
+ $error_msg = "Action response is not valid!";
+ }
+
+ return $array[0];
+ }
+
+ return $array[count($array) - 1];
+ }
+
+ function getValueOfResponse($responseArray, $name){
+// print_r('name: ' . $name);
+
+ for($i = 0; $i < count($responseArray); $i++)
+ {
+// print_r($responseArray[$i]['tag'] . '</br>');
+
+ if(ereg($name."$", $responseArray[$i]['tag']) == false){
+ continue;
+ }else{
+ return $responseArray[$i]['value'];
+ }
+ }
+ }
+?>
\ No newline at end of file
Added: CometVisu/trunk/visu/plugins/upnpcontroller/volume.php
===================================================================
--- CometVisu/trunk/visu/plugins/upnpcontroller/volume.php (rev 0)
+++ CometVisu/trunk/visu/plugins/upnpcontroller/volume.php 2012-01-28 21:33:09 UTC (rev 669)
@@ -0,0 +1,50 @@
+<?php
+/* volume.php (c) 2012 by Mark K. [mr dot remy at gmx dot de]
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+*/
+
+require 'upnpctrl_util.php';
+
+//header("content-type: text/html");
+header("content-type: text/json");
+$volume = $_GET['volume'];
+
+$cmd_setvolume='POST /MediaRenderer/RenderingControl/Control HTTP/1.1
+CONNECTION: close
+HOST: '.$address.':1400
+CONTENT-LENGTH: 32'.strlen($volume).'
+CONTENT-TYPE: text/xml; charset="utf-8"
+SOAPACTION: "urn:schemas-upnp-org:service:RenderingControl:1#SetVolume"
+
+<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetVolume xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><Channel>Master</Channel><DesiredVolume>'.$volume.'</DesiredVolume></u:SetVolume></s:Body></s:Envelope>';
+
+$actionResponse = sendUpnpAction($cmd_setvolume, $address, $port);
+
+//echo "actionResponse xml: ";
+//print_r($actionResponse);
+//echo "</br>'";
+
+$xmlParser = xml_parser_create("UTF-8");
+xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, "UTF-8");
+xml_parse_into_struct($xmlParser, $actionResponse, $actionResponseArray, $index);
+xml_parser_free($xmlParser);
+
+//print_r($actionResponseArray);
+//print_r($index);
+
+print_r("{\"actionstatus\" : 'OK'}");
+
+?>
\ No newline at end of file
Modified: CometVisu/trunk/visu/visu_config.xml
===================================================================
--- CometVisu/trunk/visu/visu_config.xml 2012-01-25 17:18:43 UTC (rev 668)
+++ CometVisu/trunk/visu/visu_config.xml 2012-01-28 21:33:09 UTC (rev 669)
@@ -4,6 +4,7 @@
<plugins>
<plugin name="colorchooser"/>
<plugin name="diagram"/>
+ <plugin name="upnpcontroller"/>
</plugins>
<mappings>
<mapping name="Open_Close">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|