/Server/services/sonos_hacsvc/PHPSonos.inc.php
PHP | 2320 lines | 1906 code | 95 blank | 319 comment | 35 complexity | 512ae70c6dbd9a0517a708a3529a267d MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <?php
- // URL to gen documentation on my (br) system http://192.168.0.5:82/user/PhpDocumentor/
- /**
- * PHPSonos.inc.php
- *
- * PHPSonos class originally released as: Sonos PHP Script - Copyright: Michael Maroszek - Version: 1.0, 09.07.2009
- *
- * Wiki: {@link http://www.ip-symcon.de/wiki/PHPSonos PHPSonos IPS-WIKI }
- *
- * @author Michael Maroszek <office@ip-symcon.de> and many others
- * @version see date of edit
- * @package PHPSonos.inc.php
- * @copyright original 1.0 version Michael Maroszek; later additions if not otherwise stated are released to public domain
- */
- /**
- * PHPSonos Class
- *
- * PHPSonos Class originally released as: Sonos PHP Script - Copyright: Michael Maroszek - Version: 1.0, 09.07.2009
- *
- * Wiki: {@link http://www.ip-symcon.de/wiki/PHPSonos PHPSonos IPS-WIKI }
- *
- * Die PHPSonos Klasse wurde von Paresy zuerst im Thread Einzelne Sonos Player ansteuern veröffentlicht und später in einer aktualisierten Fassung im Thread PHP Sonos (Klasse zum Ansteuern einzelner Player) als Klasse zur Verfügung gestellt.
- *
- * Verschiedene IPS Benutzer haben die Klasse inzwischen erweitert oder im zuletzt genannten Thread Hinweise zum Handling ausgetauscht.
- *
- * Paresy released his first version of PHPsonos in this forum thread Einzelne Sonos Player ansteuern. He later build a class and rereleased his routines in this thread: PHP Sonos (Klasse zum Ansteuern einzelner Player).
- *
- * There is a growing community of sonos enthusiasts supporting and developing PHPSONOS - we share knowledge and developements in this thread PHP Sonos (Klasse zum Ansteuern einzelner Player)
- *
- *
- *
- * <br>
- * <b>Changelog:</b><br>
- * <pre>
- *
- * - andre added setter functions
- * - 110108 - br added comments based on UPNP information from devicespy;
- * also added the function XMLsendPacket to get non filtered answers
- * - 110120 - br added Set and GetLEDState
- * - 110202 - br added GetZoneAttributes
- * - 110202 - br added GetZoneInfo
- * - 110203 - br added gestposinfo TrackURI (contains x-rincon of the zone master if we are slave)
- * - 110206 - br added AddMember(Rincon...) and RemoveMember(Rincon...)
- * - 110207 - br added RamptoVolume
- * - 110208 - br added calculation of Content-Length to some functions
- * - 110318 - br fiddled with Playmode (maybe fixed a bug)
- * - 110318 - br added Get and Set CrossfadeMode
- * - 110318 - br added SaveQueue
- * - 110328 - ta lun added GetPlaylist($value)
- * - 110328 - ta lun added GetImportedPlaylists()
- * - 110328 - ta lun added GetSonosPlaylists()
- * - 110328 - ta lun added GetCurrentPlaylist()
- * - 110328 - br corrected titel to title and other things...
- * - 110328 - br added optional parameter id to SaveQueue
- * - 110406 - br edited Seek to accept UPNP Unit parameter as option (sec. arg is Target then)
- * - 110406 - br edited GetPositionInfo to also reflect UPNP return value names
- * - 110406 - br fixed non valid soap request in seek()
- * - 110406 - br added return of CurrentURI and CurrentUriMetaData to Get (Current File or QUEUE)
- This info is needed to restart a queue, pl or radiostation
- * - 110407 - br consolidated SetRadio, SetQueue and SetAVTransportURI
- the two last now also support MetaData as optional, 2nd parameter; SetRadio supports the name of a radiostation as an optional second parameter
- * - 110529 - br GetMediaInfo now returns Radio station in the array, key is title
- * - 110529 - ta lun added browse functions
- * - 110529 - iamking added GetAlarmTime()
- * - 110529 - ta lun fixed misc bugs and GetAlarmTime() now returns an array
- * - 110530 - br edited Browse() to reflect upnp possibilities
- * - 110601 - br renamed GetAlarmtime to ListAlarms to reflect upnp Names
- * - 110601 - iamking improved ListAlarms - added ProgramURI, ProgramMetaData, PlayMode, Volume, IncludeLinkedZones
- * - 110614 - br added parameters to Browse / http://www.ip-symcon.de/forum/f53/php-sonos-klasse-ansteuern-einzelner-player-7676/index10.html#post120977
- * - 110627 - talun edited GetSonosPlaylists: urlencode file
- * - 110711 - br fixed Problems in SetAVTransportUri
- * - 110821 - br/talun edited Browse to return duration
- * - 110821 - br added GetAudioInputAttributes
- * - 110828 - br added Radiotime Radio Cover for GetPositionInfo (patching´in Raditiome Cover URI)
- * - 110901 - br shifted Radiotime Functions from getpositioninfo to new Function RadiotimeGetNowPlaying (returns array)
- * - 110905 - br fixed Bug in getpositioninfo for getting the actual Track in a playlist (quickfix)
- * - 110907 - br deleted, added and edited comment lines
- * - 110908 - br added phpdoc tags for documentation
- * - 110909 - br found sendpacket commented out in RemoveMember and reenabled the sending now (TEST?!)
- * - 110911 - br added phpdoc tags for documentation
- * - 110915 - br added PhpSonos API key/ partnerid for Intune (usable for ANYONE who uses the PHPSonos class noncommercial or commercial) - thanks to Ben@tunein for advocation and great support!
- * Drop me a note if you are a PHPSonos developer and need access to documentation of tunein APIs.
- * - 110916 - br added GetCurrentTransportActions() which returns the currently valid actions (nearly always returns all actions "Play, Stop, Pause, Seek, Next, Previous" for me)...
- * - 110916 - br added Get and SetInvisible to make it possible to change visibilty for party mode or other things (kids should not see their player in the night *g)
- * - 110916 - br improved phpdoc tags
- * - 111021 - br added soap parameters to ramptovolume (function did not work anymore without)
- * - 111028 - br added parameters id and parentid to setradio (only very rare use for this)
- * - 111130 - br minor improvements: phpdoc tags
- * - 120205 - PeterChrisben/br improved phpdoc for setplaymode and gettransportsettings
- * </pre>
- *
- * <b>Links:</b><br>
- * {@link http://travelmarx.blogspot.com/2010/06/exploring-sonos-via-upnp.html }<br>
- * {@link http://travelmarx.blogspot.com/2011/01/extracting-sonos-playlist-simple-sonos.html }<br>
- * {@link http://opentools.homeip.net/dev-tools-for-upnp }<br>
- * {@link http://www.ip-symcon.de/forum/f53/php-sonos-klasse-ansteuern-einzelner-player-7676/ }<br>
- * {@link http://your.sonos.i.p:1400/status }<br>
- * {@link http://your.sonos.i.p1400/support/review }<br>
- * {@link http://play.er.i.p:1400/xml/zone_player.xml }<br>
- *
- * @author Michael Maroszek <office@ip-symcon.de> and many others
- * @version see date of edit
- * @package PHPSonos
- * @copyright original 1.0 version Michael Maroszek; later additions if not otherwise stated are released to public domain
- **/
- class PHPSonos {
- private $address = "";
- public function __construct( $address ) {
- $this->address = $address;
- // Maybe we could integrate/provide some more info here (ZoneAttr / Zoneinfo etc.) ?
- }
- /*
- * urn:schemas-upnp-org:device:ZonePlayer:1
- * http://play.er.i.p:1400/xml/zone_player.xml
- */
- /*
- * urn:upnp-org:serviceId:AlarmClock
- * Not fully implemented
- */
-
- /**
- * Returns a list of alarms from sonos device
- *
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:ZonePlayer:1
- * - <b>WSDL:</b> http://play.er.i.p:1400/xml/zone_player.xml
- * - <b>Service:</b> urn:upnp-org:serviceId:AlarmClock
- *
- * @return Array
- *
- * @link http://www.ip-symcon.de/forum/f53/php-sonos-klasse-ansteuern-einzelner-player-7676/index9.html#post120731 Forum-Post
- */
- public function ListAlarms()
- {
- $header='POST /AlarmClock/Control HTTP/1.1
- SOAPACTION: "urn:schemas-upnp-org:service:AlarmClock:1#ListAlarms"
- CONTENT-TYPE: text/xml; charset="utf-8"
- HOST: '.$this->address.':1400';
- $xml='<?xml version="1.0" encoding="utf-8"?> <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
- <s:Body>
- <u:AlarmClock xmlns:u="urn:schemas-upnp-org:service:AlarmClock:1"/>
- </s:Body>
- </s:Envelope>';
- $content=$header . '
- Content-Length: '. strlen($xml) .'
- '. $xml;
- $returnContent = $this->XMLsendPacket($content);
- $returnContent = substr($returnContent, stripos($returnContent, '<'));
- $returnContent = substr($returnContent, 0, strrpos($returnContent, '>') + 4);
- $returnContent = str_replace(array("<", ">", """, "&", "%3a", "%2f", "%25"), array("<", ">", "\"", "&", ":", "/", "%"), $returnContent);
- $xmlr = new SimpleXMLElement($returnContent);
- $liste = array();
- for($i=0,$size=count($xmlr);$i<$size;$i++)
- {
- $attr = $xmlr->Alarm[$i]->attributes();
- $liste[$i]['ID'] = (string)$attr['ID'];
- $liste[$i]['StartTime'] = (string)$attr['StartTime'];
- $liste[$i]['Duration'] = (string)$attr['Duration'];
- $liste[$i]['Recurrence'] = (string)$attr['Recurrence'];
- $liste[$i]['Enabled'] = (string)$attr['Enabled'];
- $liste[$i]['RoomUUID'] = (string)$attr['RoomUUID'];
- $liste[$i]['ProgramURI'] = (string)$attr['ProgramURI'];
- $liste[$i]['ProgramMetaData'] = (string)$attr['ProgramMetaData'];
- $liste[$i]['PlayMode'] = (string)$attr['PlayMode'];
- $liste[$i]['Volume'] = (string)$attr['Volume'];
- $liste[$i]['IncludeLinkedZones'] = (string)$attr['IncludeLinkedZones'];
- }
- return $liste;
- }
-
- /**
- * Updates an existing alarm
- *
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:ZonePlayer:1
- * - <b>WSDL:</b> http://play.er.i.p:1400/xml/zone_player.xml
- * - <b>Service:</b> urn:upnp-org:serviceId:AlarmClock
- * - <b>Returns:</b> None
- * - <b>NOTE:</b> fill in
- *
- * @param string $id Id of the Alarm
- * @param string $startzeit StartLocalTime
- * @param string $duration Duration
- * @param string $welchetage Recurrence
- * @param string $an Enabled? (true/false)
- * @param string $roomid Room UUID
- * @param string $programm ProgramUri
- * @param string $programmmeta ProgramMetadata
- * @param string $playmode PlayMode
- * @param string $volume Volume
- * @param string $linkedzone IncludeLinkedZones
- *
- * @return Void
- *
- * @link http://www.ip-symcon.de/forum/f53/php-sonos-klasse-ansteuern-einzelner-player-7676/index9.html#post120710 Forum-post
- */
- public function UpdateAlarm($id, $startzeit, $duration, $welchetage, $an, $roomid, $programm, $programmeta, $playmode, $volume, $linkedzone)
- {
- $payload = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
- <s:Body><u:UpdateAlarm xmlns:u="urn:schemas-upnp-org:service:AlarmClock:1">
- <ID>'.$id.'</ID>
- <StartLocalTime>'.$startzeit.'</StartLocalTime>
- <Duration>'.$duration.'</Duration>
- <Recurrence>'.$welchetage.'</Recurrence>
- <Enabled>'.$an.'</Enabled>
- <RoomUUID>'.$roomid.'</RoomUUID>
- <ProgramURI>'.htmlspecialchars($programm).'</ProgramURI>
- <ProgramMetaData>'.htmlspecialchars($programmeta).'</ProgramMetaData>
- <PlayMode>'.$playmode.'</PlayMode>
- <Volume>'.$volume.'</Volume>
- <IncludeLinkedZones>'.$linkedzone.'</IncludeLinkedZones>
- </u:updateAlarm></s:Body></s:Envelope>';
- $content='POST /AlarmClock/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->address.':1400
- CONTENT-LENGTH: '.strlen($payload).'
- CONTENT-TYPE: text/xml; charset="utf-8"
- SOAPACTION: "urn:schemas-upnp-org:service:AlarmClock:1#UpdateAlarm"
- '.$payload;
- $this->sendPacket($content);
- }
-
- /* urn:upnp-org:serviceId:AudioIn */
- // Not fully implemented
-
- /**
- * Get information of devices inputs
- *
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:ZonePlayer:1
- * - <b>WSDL:</b> http://play.er.i.p:1400/xml/zone_player.xml
- * - <b>Service:</b> urn:upnp-org:serviceId:AudioIn
- * - <b>Returns:</b> Array
- * - <b>NOTE:</b> fill in
- *
- * @return Array
- *
- * @link http://www.ip-symcon.de/forum/f53/php-sonos-klasse-ansteuern-einzelner-player-7676/index15.html#post131481 Forum-Post
- */
- public function GetAudioInputAttributes() // added br
- {
- $header='POST /AudioIn/Control HTTP/1.1
- SOAPACTION: "urn:schemas-upnp-org:service:AudioIn:1#GetAudioInputAttributes"
- CONTENT-TYPE: text/xml; charset="utf-8"
- HOST: '.$this->address.':1400';
- $xml='<?xml version="1.0" encoding="utf-8"?>
- <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
- <s:Body>
- <u:GetAudioInputAttributes xmlns:u="urn:schemas-upnp-org:service:AudioIn:1"/>
- </s:Body>
- </s:Envelope>';
- $content=$header . '
- Content-Length: '. strlen($xml) .'
- '. $xml;
- $returnContent = $this->XMLsendPacket($content);
- $xmlParser = xml_parser_create("UTF-8");
- xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
- xml_parse_into_struct($xmlParser, $returnContent, $vals, $index);
- xml_parser_free($xmlParser);
- $AudioInReturn = Array();
- $key="CurrentName"; // Lookfor
- if ( isset($index[strtoupper($key)][0]) and isset($vals[ $index[strtoupper($key)][0] ]['value'])) {$AudioInReturn[$key] = $vals[ $index[strtoupper($key)][0] ]['value'];
- } else { $AudioInReturn[$key] = ""; }
- $key="CurrentIcon"; // Lookfor
- if ( isset($index[strtoupper($key)][0]) and isset($vals[ $index[strtoupper($key)][0] ]['value'])) {$AudioInReturn[$key] = $vals[ $index[strtoupper($key)][0] ]['value'];
- } else { $AudioInReturn[$key] = ""; }
- return $AudioInReturn; //Assoziatives Array
- }
-
-
- /* urn:upnp-org:serviceId:DeviceProperties */
- /**
- * Reads Zone Attributes
- *
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:ZonePlayer:1
- * - <b>WSDL:</b> http://play.er.i.p:1400/xml/zone_player.xml
- * - <b>Service:</b> urn:upnp-org:serviceId:DeviceProperties
- * - <b>Returns:</b> Example:
- * <code> Array
- * (
- * [CurrentZoneName] => Kxz Boxyz
- * [CurrentIcon] => x-rincon-roomicon:office
- * )
- * </code>
- * @return Array
- *
- * @link http://www.ip-symcon.de/wiki/PHPSonos Wiki
- *
- **/
- public function GetZoneAttributes() // added br
- {
- $header='POST /DeviceProperties/Control HTTP/1.1
- SOAPACTION: "urn:schemas-upnp-org:service:DeviceProperties:1#GetZoneAttributes"
- CONTENT-TYPE: text/xml; charset="utf-8"
- HOST: '.$this->address.':1400';
- $xml='<?xml version="1.0" encoding="utf-8"?>
- <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
- <s:Body>
- <u:GetZoneAttributes xmlns:u="urn:schemas-upnp-org:service:DeviceProperties:1"/>
- </s:Body>
- </s:Envelope>';
- $content=$header . '
- Content-Length: '. strlen($xml) .'
- '. $xml;
- $returnContent = $this->XMLsendPacket($content);
- $xmlParser = xml_parser_create("UTF-8");
- xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
- xml_parse_into_struct($xmlParser, $returnContent, $vals, $index);
- xml_parser_free($xmlParser);
- $ZoneAttributes = Array();
- $key="CurrentZoneName"; // Lookfor
- if ( isset($index[strtoupper($key)][0]) and isset($vals[ $index[strtoupper($key)][0] ]['value'])) {$ZoneAttributes[$key] = $vals[ $index[strtoupper($key)][0] ]['value'];
- } else { $ZoneAttributes[$key] = ""; }
- $key="CurrentIcon"; // Lookfor
- if ( isset($index[strtoupper($key)][0]) and isset($vals[ $index[strtoupper($key)][0] ]['value'])) {$ZoneAttributes[$key] = $vals[ $index[strtoupper($key)][0] ]['value'];
- } else { $ZoneAttributes[$key] = ""; }
- return $ZoneAttributes; //Assoziatives Array
- }
- /**
- * Reads Zone Information
- *
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:ZonePlayer:1
- * - <b>WSDL:</b> http://play.er.i.p:1400/xml/zone_player.xml
- * - <b>Service:</b> urn:upnp-org:serviceId:DeviceProperties
- * - <b>Returns:</b> Example:
- * <code> Array
- * (
- * [SerialNumber] => 00-zz-58-32-yy-xx:5
- * [SoftwareVersion] => 15.4-442xx
- * [DisplaySoftwareVersion] => 3.5.x
- * [HardwareVersion] => 1.16.3.z-y
- * [IPAddress] => yyy.168.z.xxx
- * [MACAddress] => 00:zz:58:32:yy:xx
- * [CopyrightInfo] => Š 2004-2007 Sonos, Inc. All Rights Reserved.
- * [ExtraInfo] => OTP: 1.1.x(1-yy-3-0.x)
- *)
- * </code>
- *
- * @return Array
- *
- * @link http://www.ip-symcon.de/wiki/PHPSonos Wiki
- */
- public function GetZoneInfo() // added br
- {
- $header='POST /DeviceProperties/Control HTTP/1.1
- SOAPACTION: "urn:schemas-upnp-org:service:DeviceProperties:1#GetZoneInfo"
- CONTENT-TYPE: text/xml; charset="utf-8"
- HOST: '.$this->address.':1400';
- $xml='<?xml version="1.0" encoding="utf-8"?>
- <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
- <s:Body>
- <u:GetZoneInfo xmlns:u="urn:schemas-upnp-org:service:DeviceProperties:1"/>
- </s:Body>
- </s:Envelope>';
- $content=$header . '
- Content-Length: '. strlen($xml) .'
- '. $xml;
- $returnContent = $this->XMLsendPacket($content);
- $xmlParser = xml_parser_create("UTF-8");
- xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
- xml_parse_into_struct($xmlParser, $returnContent, $vals, $index);
- xml_parser_free($xmlParser);
- $ZoneInfo = Array();
- $key="SerialNumber"; // Lookfor
- if ( isset($index[strtoupper($key)][0]) and isset($vals[ $index[strtoupper($key)][0] ]['value'])) {$ZoneInfo[$key] = $vals[ $index[strtoupper($key)][0] ]['value'];
- } else { $ZoneInfo[$key] = ""; }
- $key="SoftwareVersion"; // Lookfor
- if ( isset($index[strtoupper($key)][0]) and isset($vals[ $index[strtoupper($key)][0] ]['value'])) {$ZoneInfo[$key] = $vals[ $index[strtoupper($key)][0] ]['value'];
- } else { $ZoneInfo[$key] = ""; }
- $key="SoftwareVersion"; // Lookfor
- if ( isset($index[strtoupper($key)][0]) and isset($vals[ $index[strtoupper($key)][0] ]['value'])) {$ZoneInfo[$key] = $vals[ $index[strtoupper($key)][0] ]['value'];
- } else { $ZoneInfo[$key] = ""; }
- $key="DisplaySoftwareVersion"; // Lookfor
- if ( isset($index[strtoupper($key)][0]) and isset($vals[ $index[strtoupper($key)][0] ]['value'])) {$ZoneInfo[$key] = $vals[ $index[strtoupper($key)][0] ]['value'];
- } else { $ZoneInfo[$key] = ""; }
- $key="HardwareVersion"; // Lookfor
- if ( isset($index[strtoupper($key)][0]) and isset($vals[ $index[strtoupper($key)][0] ]['value'])) {$ZoneInfo[$key] = $vals[ $index[strtoupper($key)][0] ]['value'];
- } else { $ZoneInfo[$key] = ""; }
- $key="IPAddress"; // Lookfor
- if ( isset($index[strtoupper($key)][0]) and isset($vals[ $index[strtoupper($key)][0] ]['value'])) {$ZoneInfo[$key] = $vals[ $index[strtoupper($key)][0] ]['value'];
- } else { $ZoneInfo[$key] = ""; }
- $key="MACAddress"; // Lookfor
- if ( isset($index[strtoupper($key)][0]) and isset($vals[ $index[strtoupper($key)][0] ]['value'])) {$ZoneInfo[$key] = $vals[ $index[strtoupper($key)][0] ]['value'];
- } else { $ZoneInfo[$key] = ""; }
- $key="CopyrightInfo"; // Lookfor
- if ( isset($index[strtoupper($key)][0]) and isset($vals[ $index[strtoupper($key)][0] ]['value'])) {$ZoneInfo[$key] = $vals[ $index[strtoupper($key)][0] ]['value'];
- } else { $ZoneInfo[$key] = ""; }
- $key="ExtraInfo"; // Lookfor
- if ( isset($index[strtoupper($key)][0]) and isset($vals[ $index[strtoupper($key)][0] ]['value'])) {$ZoneInfo[$key] = $vals[ $index[strtoupper($key)][0] ]['value'];
- } else { $ZoneInfo[$key] = ""; }
- return $ZoneInfo; //Assoziatives Array
- }
- /**
- * Sets the state of the white LED
- *
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:ZonePlayer:1
- * - <b>WSDL:</b> http://play.er.i.p:1400/xml/zone_player.xml
- * - <b>Service:</b> urn:upnp-org:serviceId:DeviceProperties
- *
- * @param string $state true||false value or On / Off
- *
- * @return Boolean
- *
- * @link http://www.ip-symcon.de/wiki/PHPSonos Wiki
- */
- public function SetLEDState($state) // added br
- {
- if($state=="On") { $state = "On"; } else
- { if($state=="Off") { $state = "Off"; } else {
- if($state) { $state = "On"; } else { $state = "Off"; }
- }
- }
-
- $content='POST /DeviceProperties/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->address.':1400
- CONTENT-LENGTH: 250
- CONTENT-TYPE: text/xml; charset="utf-8"
- SOAPACTION: "urn:schemas-upnp-org:service:DeviceProperties:1#SetLEDState"
- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetLEDState xmlns:u="urn:schemas-upnp-org:service:DeviceProperties:1"><DesiredLEDState>' .$state. '</DesiredLEDState><u:SetLEDState></s:Body></s:Envelope>';
- return (bool)$this->sendPacket($content);
- }
- /**
- * Gets the state of the white LED
- *
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:ZonePlayer:1
- * - <b>WSDL:</b> http://play.er.i.p:1400/xml/zone_player.xml
- * - <b>Service:</b> urn:upnp-org:serviceId:DeviceProperties
- *
- *
- * @return Boolean
- *
- * @link http://www.ip-symcon.de/wiki/PHPSonos Wiki
- */
- public function GetLEDState() // added br
- {
- $content='POST /DeviceProperties/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->address.':1400
- CONTENT-LENGTH: 250
- CONTENT-TYPE: text/xml; charset="utf-8"
- SOAPACTION: "urn:schemas-upnp-org:service:DeviceProperties:1#GetLEDState"
- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetLEDState xmlns:u="urn:schemas-upnp-org:service:DeviceProperties:1"><InstanceID>0</InstanceID><u:GetLEDState></s:Body></s:Envelope>';
- if ($this->sendPacket($content)=="On") { return(true); }else return(false);
- }
- /**
- * Sets ZP to visible or unvisable
- *
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:ZonePlayer:1
- * - <b>WSDL:</b> http://play.er.i.p:1400/xml/zone_player.xml
- * - <b>Service:</b> urn:upnp-org:serviceId:DeviceProperties
- * - <b>Returns:</b> True or False for invisble status
- * - <b>NOTE:</b> It is highly *NOT* recommended to try this function if you don´t know what it will do. Don´t cry if you miss a Zoneplayer!!
- *
- * @param string $state integer true||false value or string True/ False
- *
- * @return Boolean
- *
- * @link http://www.ip-symcon.de/wiki/PHPSonos Wiki
- */
- public function SetInvisible($state) // added br 110916
- {
- if($state=="True") { $state = "True"; } else
- { if($state=="False") { $state = "False"; } else {
- if($state) { $state = "True"; } else { $state = "False"; }
- }
- }
- $content='POST /DeviceProperties/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->address.':1400
- CONTENT-LENGTH: 250
- CONTENT-TYPE: text/xml; charset="utf-8"
- SOAPACTION: "urn:schemas-upnp-org:service:DeviceProperties:1#SetInvisible"
- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetInvisible xmlns:u="urn:schemas-upnp-org:service:DeviceProperties:1"><DesiredInvisible>' .$state. '</DesiredInvisible><u:SetInvisible></s:Body></s:Envelope>';
- return (bool)$this->sendPacket($content);
- }
- /**
- * Gets ZP invisible information
- *
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:ZonePlayer:1
- * - <b>WSDL:</b> http://play.er.i.p:1400/xml/zone_player.xml
- * - <b>Service:</b> urn:upnp-org:serviceId:DeviceProperties
- * - <b>Returns:</b> True or False for invisble status
- * - <b>NOTE:</b> If you miss a Zoneplayer try this!!
- *
- * @return Boolean
- *
- * @link http://www.ip-symcon.de/wiki/PHPSonos Wiki
- */
- public function GetInvisible() // added br 110916
- {
- $content='POST /DeviceProperties/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->address.':1400
- CONTENT-LENGTH: 250
- CONTENT-TYPE: text/xml; charset="utf-8"
- SOAPACTION: "urn:schemas-upnp-org:service:DeviceProperties:1#GetInvisible"
- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetInvisible xmlns:u="urn:schemas-upnp-org:service:DeviceProperties:1"><InstanceID>0</InstanceID><u:GetInvisible></s:Body></s:Envelope>';
- if ($this->sendPacket($content)=="1") { return(true); }else return(false);
- }
- /* urn:upnp-org:serviceId:GroupManagement */
- function SubscribeZPGroupManagement($callback){ // added br
- $content='SUBSCRIBE /GroupManagement/Event HTTP/1.1
- HOST: '.$this->address.':1400
- CALLBACK: <'.$callback.'>
- NT: upnp:event
- TIMEOUT: Second-300
- Content-Length: 0
- ';
- $this->sendPacket($content);
- }
- /**
- * Adds a Member to a existing ZoneGroup
- * (a single player is also considered a existing group)
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:ZonePlayer:1
- * - <b>WSDL:</b> http://play.er.i.p:1400/xml/zone_player.xml
- * - <b>Service:</b> urn:upnp-org:serviceId:GroupManagement
- * - <b>Returns:</b> array with CurrentTransportsettings and GroupUUIDJoined as keys
- *
- *
- * @param string $MemberID LocalUUID/ Rincon of Player to add
- *
- * @return Array
- *
- * @link http://www.ip-symcon.de/wiki/PHPSonos Wiki
- */
- public function AddMember($MemberID) // added br
- {
- $header='POST /GroupManagement/Control HTTP/1.1
- SOAPACTION: "urn:schemas-upnp-org:service:GroupManagement:1#AddMember"
- CONTENT-TYPE: text/xml; charset="utf-8"
- HOST: '.$this->address.':1400';
- $xml='<?xml version="1.0" encoding="utf-8"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
- <s:Body><u:AddMember xmlns:u="urn:schemas-upnp-org:service:GroupManagement:1"><MemberID>' . $MemberID . '</MemberID>
- </u:AddMember></s:Body></s:Envelope>';
- $content=$header . '
- Content-Length: '. strlen($xml) .'
- '. $xml;
- $returnContent = $this->XMLsendPacket($content);
- $xmlParser = xml_parser_create("UTF-8");
- xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
- xml_parse_into_struct($xmlParser, $returnContent, $vals, $index);
- xml_parser_free($xmlParser);
- $ZoneAttributes = Array();
- $key="CurrentTransportSettings"; // Lookfor
- if ( isset($index[strtoupper($key)][0]) and isset($vals[ $index[strtoupper($key)][0] ]['value'])) {$ZoneAttributes[$key] = $vals[ $index[strtoupper($key)][0] ]['value'];
- } else { $ZoneAttributes[$key] = ""; }
- $key="GroupUUIDJoined"; // Lookfor
- if ( isset($index[strtoupper($key)][0]) and isset($vals[ $index[strtoupper($key)][0] ]['value'])) {$ZoneAttributes[$key] = $vals[ $index[strtoupper($key)][0] ]['value'];
- } else { $ZoneAttributes[$key] = ""; }
- return $ZoneAttributes; //Assoziatives Array
- // set AVtransporturi ist notwendig
- }
- /**
- * Removes a Member from an existing ZoneGroup
- * (a single player is also considered an existing group and the action will result in muting the player)
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:ZonePlayer:1
- * - <b>WSDL:</b> http://play.er.i.p:1400/xml/zone_player.xml
- * - <b>Service:</b> urn:upnp-org:serviceId:GroupManagement
- * - <b>Returns:</b> for now the sendPacketAnswer
- *
- * @param string $MemberID LocalUUID/ Rincon of Player to remove
- *
- * @return Sring
- *
- * @todo br 20110909 return $this->sendPacket($content); this Line was commented out; i dont understand why... changed this
- *
- * @link http://www.ip-symcon.de/wiki/PHPSonos Wiki
- */
- public function RemoveMember($MemberID) // added br
- {
- $header='POST /GroupManagement/Control HTTP/1.1
- SOAPACTION: "urn:schemas-upnp-org:service:GroupManagement:1#RemoveMember"
- CONTENT-TYPE: text/xml; charset="utf-8"
- HOST: '.$this->address.':1400';
- $xml='<?xml version="1.0" encoding="utf-8"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
- <s:Body><u:RemoveMember xmlns:u="urn:schemas-upnp-org:service:GroupManagement:1"><MemberID>' . $MemberID . '</MemberID>
- </u:RemoveMember></s:Body></s:Envelope>';
- $content=$header . '
- Content-Length: '. strlen($xml) .'
- '. $xml;
- return $this->sendPacket($content);
- }
- /* urn:upnp-org:serviceId:MusicServices */
- // Not implemented
- /* urn:upnp-org:serviceId:SystemProperties */
- // Not implemented
- /* urn:upnp-org:serviceId:ZoneGroupTopology */
- // Not implemented
- /******************* urn:schemas-upnp-org:device:MediaRenderer:1 ***********
- ***************************************************************************/
- /* urn:upnp-org:serviceId:RenderingControl */
- /**
- * Ramps Volume to $volume using $ramp_type ; different algorithms are possible
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:upnp-org:serviceId:RenderingControl
- * - <b>Returns:</b> Function Should return Rampseconds but this is NOT implemented!
- * @todo Function Should return Rampseconds but this is NOT implemented!
- * @param string $ramp_type Ramp_type<br>
- * Ramps Volume to $volume using the Method mentioned in $ramp_type as string:<br>
- * "SLEEP_TIMER_RAMP_TYPE" - mutes and ups Volume per default within 17 seconds to desiredVolume<br>
- * "ALARM_RAMP_TYPE" -Switches audio off and slowly goes to volume<br>
- * "AUTOPLAY_RAMP_TYPE" - very fast and smooth; Implemented from Sonos for the autoplay feature.<br>
- *
- * @param string $volume DesiredVolume
- *
- * @return Void
- *
- *
- * @link http://www.ip-symcon.de/wiki/PHPSonos Wiki
- */
- public function RampToVolume($ramp_type, $volume) //added br // added soap parameters 20111021
- {
- $header='POST /MediaRenderer/RenderingControl/Control HTTP/1.1
- HOST: '.$this->address.':1400
- CONTENT-TYPE: text/xml; charset="utf-8"
- SOAPACTION: "urn:schemas-upnp-org:service:RenderingControl:1#RampToVolume"
- ';
- $xml='<?xml version="1.0" encoding="utf-8"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
- <s:Body><u:RampToVolume xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><Channel>Master</Channel><RampType>'.$ramp_type.'</RampType><DesiredVolume>'.$volume.'</DesiredVolume>
- <ResetVolumeAfter>false</ResetVolumeAfter><ProgramURI></ProgramURI>
- </u:RampToVolume></s:Body></s:Envelope>';
- $content=$header . 'Content-Length: '. strlen($xml) .'
- '. $xml;
- return (int) $this->sendPacket($content);
- }
- /* urn:upnp-org:serviceId:AVTransport */
- /**
- * TEST Function for MediaRenderAVT Callback and IPS Register Vars
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1 none
- * - <b>Returns:</b> Sendpacket contents
- *
- * @param string $callback CallbackURL Well gat a HTTP Callback at this URl (SOAP)
- * @return Void
- */
- function SubscribeMRAVTransport($callback){ // added br
- $content='SUBSCRIBE /MediaRenderer/AVTransport/Event HTTP/1.1
- HOST: '.$this->address.':1400
- CALLBACK: <'.$callback.'>
- NT: upnp:event
- TIMEOUT: Second-300
- Content-Length: 0
- ';
- $this->sendPacket($content);
- }
- /**
- * Save current queue off to sonos
- *
- * - <b>NOTE:</b> If you don´t set the id to the playlist´s id you want to edit, you´ll get duplicate playlists with the same name $title!!
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> Sendpacket contents
- *
- *
- * @param string $title Title of Playlist
- * @param string $id Playlists ID (optional)
- *
- * @return string
- *
- * @link http://www.ip-symcon.de/wiki/PHPSonos Wiki
- */
- public function SaveQueue($title,$id="") // added br
- {
- $header='POST /MediaRenderer/AVTransport/Control HTTP/1.1
- SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#SaveQueue"
- CONTENT-TYPE: text/xml; charset="utf-8"
- HOST: '.$this->address.':1400';
- $xml='<?xml version="1.0" encoding="utf-8"?>
- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body>
- <u:SaveQueue xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><Title>'.$title.'</Title><ObjectID>'.$id.'</ObjectID></u:SaveQueue>
- </s:Body>
- </s:Envelope>';
- $content=$header . '
- Content-Length: '. strlen($xml) .'
- '. $xml;
- $returnContent = $this->sendPacket($content);
- }
- /**
- * Get info on actual crossfademode
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> Boolean
- *
- *
- * @return Boolean
- */
- public function GetCrossfadeMode() // added br
- {
- $header='POST /MediaRenderer/AVTransport/Control HTTP/1.1
- HOST: '.$this->address.':1400
- CONTENT-TYPE: text/xml; charset="utf-8"
- SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#GetCrossfadeMode"
- ';
- $xml='<?xml version="1.0" encoding="utf-8"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
- <s:Body><u:GetCrossfadeMode xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID>
- </u:GetCrossfadeMode></s:Body></s:Envelope>';
- $content=$header . 'Content-Length: '. strlen($xml) .'
- '. $xml;
- return (bool)$this->sendPacket($content);
- }
- /**
- * Set crossfade to true or false
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> Void; shoud return sendpacket return
- *
- * @param string $mode Enable/ Disable = 1/0 (string) = true /false (boolean)
- *
- * @return Void
- *
- * @link http://www.ip-symcon.de/wiki/PHPSonos Wiki
- */
- public function SetCrossfadeMode($mode) // added br
- {
- if($mode) { $mode = "1"; } else { $mode = "0"; }
- $header='POST /MediaRenderer/AVTransport/Control HTTP/1.1
- HOST: '.$this->address.':1400
- CONTENT-TYPE: text/xml; charset="utf-8"
- SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#SetCrossfadeMode"
- ';
- $xml='<?xml version="1.0" encoding="utf-8"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
- <s:Body><u:SetCrossfadeMode xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><CrossfadeMode>'.$mode.'</CrossfadeMode></u:SetCrossfadeMode></u:SetCrossfadeMode></s:Body></s:Envelope>';
- $content=$header . 'Content-Length: '. strlen($xml) .'
- '. $xml;
- $this->sendPacket($content);
-
- }
- /**
- * STOP Stops playback
- *
- * - <b>NOTE:</b> It is sometimes necessary to send a stop after removing a zone from a group
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> Void
- * @todo return should be sendpacket contents
- *
- * @return Void
- */
- public function Stop()
- {
- $content='POST /MediaRenderer/AVTransport/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->address.':1400
- CONTENT-LENGTH: 250
- CONTENT-TYPE: text/xml; charset="utf-8"
- SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Stop"
- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:Stop xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID></u:Stop></s:Body></s:Envelope>';
- $this->sendPacket($content);
- }
- /**
- * PAUSE pauses playback
- *
- * - <b>NOTE:</b> It is NOT always possible to send a PAUSE command (so you may get an error)!!
- * Please look at the Soap Method GetCurrentTransportActions (which returns valid actions)
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> Void
- * @todo return should be sendpacket contents
- *
- * @return Void
- */
- public function Pause()
- {
- $content='POST /MediaRenderer/AVTransport/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->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>';
- $this->sendPacket($content);
- }
- /**
- * PLAY plays or continues playback
- *
- * - <b>NOTE:</b> It is sometimes necessary to send a play after messing with zonegroups and/or starting a new play on a new uri
- * Please look at the Soap Method GetCurrentTransportActions (which returns valid actions)
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> Void; shoud be sendpacket contents
- *
- * @return Void
- */
- public function Play()
- {
- $content='POST /MediaRenderer/AVTransport/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->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>';
- $this->sendPacket($content);
- }
-
- /**
- * NEXT
- *
- * - <b>NOTE:</b> Please look at the Soap Method GetCurrentTransportActions (which returns valid actions)
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> Void; shoud be sendpacket contents
- *
- * @return Void
- */
- public function Next()
- {
-
- $content='POST /MediaRenderer/AVTransport/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->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>';
- $this->sendPacket($content);
- }
-
- /**
- * PREVIOUS
- *
- * - <b>NOTE:</b> Please look at the Soap Method GetCurrentTransportActions (which returns valid actions)
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> Void; shoud be sendpacket contents
- *
- * @return Void
- */
- public function Previous()
- {
-
- $content='POST /MediaRenderer/AVTransport/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->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>';
- $this->sendPacket($content);
- }
-
- /**
- * SEEK
- *
- * - <b>NOTE:</b> Please look at the Soap Method GetCurrentTransportActions (which returns valid actions)
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> String; shoud be sendpacket contents as array
- *
- * @param string $arg1 Unit ("TRACK_NR" || "REL_TIME" || "SECTION")
- * @param string $arg2 Target (if this Arg is not set Arg1 is considered to be "REL_TIME and the real arg1 value is set as arg2 value)
- *
- * @return String
- */
- public function Seek($arg1,$arg2="NONE")
- {
- // Abwärtskompatibel zu Paresys Original sein // edited by br
- if ($arg2=="NONE"){
- $Unit="REL_TIME"; $position=$arg1;
- } else {$Unit=$arg1; $position=$arg2;}
- $header='POST /MediaRenderer/AVTransport/Control HTTP/1.1
- SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Seek"
- CONTENT-TYPE: text/xml; charset="utf-8"
- CONNECTION: close
- HOST: '.$this->address.':1400';
- $xml='<?xml version="1.0" encoding="utf-8"?>
- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:Seek xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><Unit>'. $Unit .'</Unit><Target>'.$position.'</Target></u:Seek></s:Envelope></s:Body></s:Envelope>';
- $content=$header . '
- Content-Length: '. strlen($xml) .'
- '. $xml;
- $returnContent = $this->sendPacket($content);
- }
-
- /**
- * REWIND
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> String
- * @todo should be sendpacket Return
- *
- * - <b>SOAP</b> this Functions calls seek REL_TIME with target set to 00:00:00
- * There is a also a function called previous.
- *
- * @return String
- */
- public function Rewind()
- {
-
- $content='POST /MediaRenderer/AVTransport/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->address.':1400
- CONTENT-LENGTH: 296
- CONTENT-TYPE: text/xml; charset="utf-8"
- SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Seek"
- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:Seek xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><Unit>REL_TIME</Unit><Target>00:00:00</Target></u:Seek></s:Body></s:Envelope>';
- $this->sendPacket($content);
- }
-
- /**
- * Sets volume for a player
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> String; sendpacket Return
- *
- *
- * @param string $volume Volume in percent
- *
- * @return String
- */
- public function SetVolume($volume)
- {
- $content='POST /MediaRenderer/RenderingControl/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->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>';
- $this->sendPacket($content);
- }
-
- /**
- * Gets current volume information from player
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> String; sendpacket Return
- *
- * @return String
- */
- public function GetVolume()
- {
- $content='POST /MediaRenderer/RenderingControl/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->address.':1400
- CONTENT-LENGTH: 290
- CONTENT-TYPE: text/xml; charset="utf-8"
- SOAPACTION: "urn:schemas-upnp-org:service:RenderingControl:1#GetVolume"
- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetVolume xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetVolume></s:Body></s:Envelope>';
- return (int)$this->sendPacket($content);
- }
-
- /**
- * Sets mute/ unmute for a player
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> String; sendpacket Return
- *
- * @param string $mute Mute unmute as (boolean)true/false or (string)1/0
- *
- * @return String
- */
- public function SetMute($mute)
- {
- if($mute) { $mute = "1"; } else { $mute = "0"; }
- $content='POST /MediaRenderer/RenderingControl/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->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>';
- $this->sendPacket($content);
- }
-
- /**
- * Gets mute/ unmute status for a player
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> String; sendpacket Return
- *
- * @return string
- */
- public function GetMute()
- {
- $content='POST /MediaRenderer/RenderingControl/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->address.':1400
- CONTENT-LENGTH: 286
- 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></u:GetMute></s:Body></s:Envelope>';
- return (bool)$this->sendPacket($content);
- }
-
- /**
- * Sets Playmode for a renderer (could affect more than one zone!)
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> String; sendpacket Return
- * - <b>NOTE:</b>
- * <PRE>
- * NORMAL = SHUFFLE and REPEAT -->FALSE
- * REPEAT_ALL = REPEAT --> TRUE, Shuffle --> FALSE
- * SHUFFLE_NOREPEAT = SHUFFLE -->TRUE / REPEAT = FALSE
- * SHUFFLE = SHUFFLE and REPEAT -->TRUE </PRE>
- *
- * @param string $mode "NORMAL" || "REPEAT_ALL" || "SHUFFLE_NOREPEAT" || "SHUFFLE"
- *
- * @return String
- */
- public function SetPlayMode($mode)
- {
- $content='POST /MediaRenderer/AVTransport/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->address.':1400
- CONTENT-LENGTH: '.(291+strlen($mode)).'
- CONTENT-TYPE: text/xml; charset="utf-8"
- SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#SetPlayMode"
- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetPlayMode xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><NewPlayMode>'.$mode.'</NewPlayMode></u:SetPlayMode></s:Body></s:Envelope>';
- $this->sendPacket($content);
- }
-
- /**
- * Gets transport settings for a renderer
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> Array with "repeat" and "shuffle" as keys and true/false as value
- * - <b>NOTE:</b>
- * <PRE>
- * SOAP return sometimes is PLAYING; I don´t know what this means, maybe only Radio (see the code below).
- *
- * NORMAL = SHUFFLE and REPEAT -->FALSE
- * REPEAT_ALL = REPEAT --> TRUE, Shuffle --> FALSE
- * SHUFFLE_NOREPEAT = SHUFFLE -->TRUE / REPEAT = FALSE
- * SHUFFLE = SHUFFLE and REPEAT -->TRUE </PRE>
- *
- * @todo: what is PLAYING??? TAG_NOTE_BR
- *
- * @return Array
- */
- public function GetTransportSettings()
- {
- $content='POST /MediaRenderer/AVTransport/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->address.':1400
- CONTENT-LENGTH: 282
- CONTENT-TYPE: text/xml; charset="utf-8"
- SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#GetTransportSettings"
- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetTransportSettings xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID></u:GetTransportSettings></s:Body></s:Envelope>';
- $returnContent = $this->sendPacket($content);
- // echo "\n===" . $this->address. "====\n" . $returnContent . "\n===\n";
- if (strstr($returnContent, "NORMAL") !== false) {
- return Array (
- "repeat" => false,
- "shuffle" => false
- );
- } elseif (strstr($returnContent, "REPEAT_ALL") !== false) {
- return Array (
- "repeat" => true,
- "shuffle" => false
- );
-
- } elseif (strstr($returnContent, "SHUFFLE_NOREPEAT") !== false) {
- return Array (
- "repeat" => false,
- "shuffle" => true
- );
- } elseif (strstr($returnContent, "SHUFFLE") !== false) {
- return Array (
- "repeat" => true,
- "shuffle" => true
- );
- }
- /* } elseif (strstr($returnContent, "PLAYING") !== false) {
- return Array (
- "repeat" => false,
- "shuffle" => true
- );
- } */
- }
- /**
- * Gets transport settings for a renderer
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> String (comma sep.) with available actions
- * - <b>NOTE:</b>
- *
- * @return String
- */
- public function GetCurrentTransportActions()
- {
- $content='POST /MediaRenderer/AVTransport/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->address.':1400
- CONTENT-LENGTH: 282
- CONTENT-TYPE: text/xml; charset="utf-8"
- SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#GetCurrentTransportActions"
- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:GetCurrentTransportActions xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID></u:GetCurrentTransportActions></s:Body></s:Envelope>';
- $returnContent = $this->sendPacket($content);
- // echo "\n===" . $this->address. "====\n" . $returnContent . "\n===\n";
- $ret=preg_replace("#(.*)<Actions>(.*?)\</Actions>(.*)#is",'$2',$returnContent);
- return $ret;
- }
- /**
- * Gets transport settings for a renderer
- *
- * - <b>Device:</b> urn:schemas-upnp-org:device:MediaRenderer:1
- * - <b>WSDL:</b> fill in
- * - <b>Service:</b> urn:schemas-upnp-org:service:AVTransport:1
- * - <b>Returns:</b> Array with "repeat" and "shuffle" as keys and true/false as value
- * - <b>NOTE:</b> SOAP return sometimes is PLAYING; I don´t know what this means, maybe only Radio (see the code below).
- *
- * @return Array
- */
- public function GetTransportInfo()
- {
- $content='POST /MediaRenderer/AVTransport/Control HTTP/1.1
- CONNECTION: close
- HOST: '.$this->address.':1400
- …
Large files files are truncated, but you can click here to view the full file