-
Notifications
You must be signed in to change notification settings - Fork 19
1.1 Locate Class
This class contains the methods and properties used for Locating, Loading and Saving of Devices objects.
With this latest version of the library, users are now only required to know 1 property to build the device object. This property is the Description Document URL. Unlike previous versions that required users to plug in the Device's Name and IP Address, then initialize the Device Object before using, this library NO longer uses the initialize() method. All properties for the Device Object are now automatically populated during the building of the device object.
This API provides 2 ways to create a Device object.
-
Build the Device object from the Description Document XML file.
This requires the full URL to the device's Description Document. To retrieve a list of Description Document URL's for all devices found on the network, use the locateDevices() method. See below or SonyDevice.BuildFromDocument for more information. -
Load an API device XML file using the DeviceLoad(path) method.
public class APILibrary.Locate()
This method replaces the prior sonyDiscovery(Null) method that is NO longer used! This method is only used to send a UPnP broadcast across the LAN to locate any UPnP/DLNA devices that are powered on or able to respond to the broadcast. Unlike the previously used sonyDiscover("IRCC") method, this method does NOT return device objects.
Syntax: APILibrary.Locate.LocateDevices();
Returns: A String List of Description Document URL's for each Device found.
Example:
List<string> fDev = mySonyLib.Locate.LocateDevices()
The list fDev
above will return a list containing the full URL to all "Device Description Document.xml" files found. For example:
http://192.168.0.100:8080/Description.xml
http://192.168.0.100:80/server.xml
http://192.168.0.110:52323/dmr.xml
See SonyDevice.BuildFromDocument(URI) for more information on how to use this list to build your device object.
===
This method will load a previously saved API device file to a device object. Populating all information without having to connect to the actual device. This is the preferred method to use once you have Found and Registered your device. Must have saved the device object using the "DeviceSave(Path, Device)" method prior to executing.
NOTE: The API device file is NOT the same as the Description Document XML file! Even though both of these files look very similar, their structures and data are very different. An API Device file is a Serialized copy of the device object. This allows users to load the device directly, without having to actually connect to it. This will tremendously speed up execution of applications, however, applications will need to check if the device is actually OnLine before tying to execute any commands.
Also, this API does NOT automatically save changes that are made to a device object while executing an application. For example: if you save an API device file before registering, the Device.Registered property will equal false. Then, once you register, it will equal true. If you do NOT re-save the device file after you register and then you try to load the device file, the Device.Registered property will be set to false. It is suggested that you have completed the registration process before saving the API device file. Also any major changes made to the device (IP address, Name, Mac Address) the Device object should be re-saved.
Syntax: mySonyLib.Locate.DeviceLoad(Path)
Path - A string value containing the FULL path to the API device file. (Including File Name)
Example:
myDevice = mySonyLib.Locate.DeviceLoad(@"C:\myDevices\BRAVIA KDL-42W828B.xml");
===
This method will save a device object to an API device file. This is a Serialized xml representation of the actual device object. Use this file to load previously found devices and to increase execution speed of your applications.
Syntax: mySonyLib.Locate.DeviceSave(Path, Device)
Path - A string value containing the FULL path to the device file. (Including File Name)
Device - A fully populated Device object.
Example:
mySonyLib.Locate.DeviceSave(@"C:\myDevices\BRAVIA KDL-42W828B.xml", myDevice);
This is a serialized XML representation of the SonyDevice object.
It will contain ALL the device properties along with their values.
This file appears to be similar to the device's Document Description XML file, but actually has a different structure to it and contains all information required to build a fully functional Device object!
The name of this file can be anything you want it to be. By default, most examples will save the Device API file using the device's NAME as the file name.
for example:
Here is an example API Device File.
<?xml version="1.0" encoding="utf-8"?>
<SonyDevice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Actionlist>
<RegisterMode>2</RegisterMode>
<RegisterUrl>http://192.168.0.15:80/cers/api/register</RegisterUrl>
<getSystemInformation>http://192.168.0.15:80/cers/api/getSystemInformation</getSystemInformation>
<getRemoteCommandList>http://192.168.0.15:80/cers/api/getRemoteCommandList</getRemoteCommandList>
<getStatus>http://192.168.0.15:80/cers/api/getStatus</getStatus>
<getText>http://192.168.0.15:80/cers/api/getText</getText>
<sendText>http://192.168.0.15:80/cers/api/sendText</sendText>
</Actionlist>
<pincode>0000</pincode>
<RenderingControl>
<serviceType>urn:schemas-upnp-org:service:RenderingControl:1</serviceType>
<friendlyServiceIdentifier>RenderingControl:1</friendlyServiceIdentifier>
<serviceID>urn:upnp-org:serviceId:RenderingControl</serviceID>
<controlURL>http://192.168.0.15:52323/upnp/control/RenderingControl</controlURL>
<eventSubURL>http://192.168.0.15:52323/upnp/event/RenderingControl</eventSubURL>
<SCPDURL>http://192.168.0.15:52323/RenderingControlSCPD.xml</SCPDURL>
<sv_Mute>false</sv_Mute>
<sv_Volume>0</sv_Volume>
<sv_InstanceID>0</sv_InstanceID>
</RenderingControl>
<ConnectionManager>
<serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>
<friendlyServiceIdentifier>ConnectionManager:1</friendlyServiceIdentifier>
<serviceID>urn:upnp-org:serviceId:ConnectionManager</serviceID>
<controlURL>http://192.168.0.15:52323/upnp/control/ConnectionManager</controlURL>
<eventSubURL>http://192.168.0.15:52323/upnp/event/ConnectionManager</eventSubURL>
<SCPDURL>http://192.168.0.15:52323/ConnectionManagerSCPD.xml</SCPDURL>
<sv_ConnectionID>0</sv_ConnectionID>
<sv_AVTransportID>0</sv_AVTransportID>
<sv_PeerConnectionID>0</sv_PeerConnectionID>
</ConnectionManager>
<AVTransport>
<serviceType>urn:schemas-upnp-org:service:AVTransport:1</serviceType>
<friendlyServiceIdentifier>AVTransport:1</friendlyServiceIdentifier>
<serviceID>urn:upnp-org:serviceId:AVTransport</serviceID>
<controlURL>http://192.168.0.15:52323/upnp/control/AVTransport</controlURL>
<eventSubURL>http://192.168.0.15:52323/upnp/event/AVTransport</eventSubURL>
<SCPDURL>http://192.168.0.15:52323/AVTransportSCPD.xml</SCPDURL>
<sv_TransportPlaySpeed>0</sv_TransportPlaySpeed>
<sv_NumberOfTracks>0</sv_NumberOfTracks>
<sv_CurrentTrack>0</sv_CurrentTrack>
<sv_A_ARG_TYPE_InstanceID>0</sv_A_ARG_TYPE_InstanceID>
</AVTransport>
<Party>
<sv_SingerCapability>0</sv_SingerCapability>
<sv_TransportPort>0</sv_TransportPort>
<sv_SessionID>0</sv_SessionID>
<sv_NumberOfListeners>0</sv_NumberOfListeners>
</Party>
<IRCC>
<serviceType>urn:schemas-sony-com:service:IRCC:1</serviceType>
<friendlyServiceIdentifier>IRCC:1</friendlyServiceIdentifier>
<serviceID>urn:schemas-sony-com:serviceId:IRCC</serviceID>
<controlURL>http://192.168.0.15:80/IRCC</controlURL>
<SCPDURL>http://192.168.0.15:80/IRCC/IRCCSCPD.xml</SCPDURL>
</IRCC>
<Name>BRAVIA55</Name>
<Manufacture>Sony Corporation</Manufacture>
<ModelName>KDL-55EX720</ModelName>
<UDN>uuid:00000000-0000-1010-8000-F0BF97F535B0</UDN>
<DeviceType>urn:schemas-upnp-org:device:MediaRenderer:1</DeviceType>
<Device_IP_Address>192.168.0.15</Device_IP_Address>
<Device_Port>52323</Device_Port>
<Commands>
<SonyCommands>
<name>Confirm</name>
<value>AAAAAQAAAAEAAABlAw==</value>
</SonyCommands>
<SonyCommands>
<name>Up</name>
<value>AAAAAQAAAAEAAAB0Aw==</value>
</SonyCommands>
<SonyCommands>
<name>Down</name>
<value>AAAAAQAAAAEAAAB1Aw==</value>
</SonyCommands>
<SonyCommands>
<name>Right</name>
<value>AAAAAQAAAAEAAAAzAw==</value>
</SonyCommands>
<SonyCommands>
<name>Left</name>
<value>AAAAAQAAAAEAAAA0Aw==</value>
</SonyCommands>
<SonyCommands>
<name>Home</name>
<value>AAAAAQAAAAEAAABgAw==</value>
</SonyCommands>
<SonyCommands>
<name>Options</name>
<value>AAAAAgAAAJcAAAA2Aw==</value>
</SonyCommands>
<SonyCommands>
<name>Return</name>
<value>AAAAAgAAAJcAAAAjAw==</value>
</SonyCommands>
<SonyCommands>
<name>Num1</name>
<value>AAAAAQAAAAEAAAAAAw==</value>
</SonyCommands>
<SonyCommands>
<name>Num2</name>
<value>AAAAAQAAAAEAAAABAw==</value>
</SonyCommands>
<SonyCommands>
<name>Num3</name>
<value>AAAAAQAAAAEAAAACAw==</value>
</SonyCommands>
<SonyCommands>
<name>Num4</name>
<value>AAAAAQAAAAEAAAADAw==</value>
</SonyCommands>
<SonyCommands>
<name>Num5</name>
<value>AAAAAQAAAAEAAAAEAw==</value>
</SonyCommands>
<SonyCommands>
<name>Num6</name>
<value>AAAAAQAAAAEAAAAFAw==</value>
</SonyCommands>
<SonyCommands>
<name>Num7</name>
<value>AAAAAQAAAAEAAAAGAw==</value>
</SonyCommands>
<SonyCommands>
<name>Num8</name>
<value>AAAAAQAAAAEAAAAHAw==</value>
</SonyCommands>
<SonyCommands>
<name>Num9</name>
<value>AAAAAQAAAAEAAAAIAw==</value>
</SonyCommands>
<SonyCommands>
<name>Num0</name>
<value>AAAAAQAAAAEAAAAJAw==</value>
</SonyCommands>
<SonyCommands>
<name>Num11</name>
<value>AAAAAQAAAAEAAAAKAw==</value>
</SonyCommands>
<SonyCommands>
<name>Num12</name>
<value>AAAAAQAAAAEAAAALAw==</value>
</SonyCommands>
<SonyCommands>
<name>Power</name>
<value>AAAAAQAAAAEAAAAVAw==</value>
</SonyCommands>
<SonyCommands>
<name>Display</name>
<value>AAAAAQAAAAEAAAA6Aw==</value>
</SonyCommands>
<SonyCommands>
<name>VolumeUp</name>
<value>AAAAAQAAAAEAAAASAw==</value>
</SonyCommands>
<SonyCommands>
<name>VolumeDown</name>
<value>AAAAAQAAAAEAAAATAw==</value>
</SonyCommands>
<SonyCommands>
<name>Mute</name>
<value>AAAAAQAAAAEAAAAUAw==</value>
</SonyCommands>
<SonyCommands>
<name>Audio</name>
<value>AAAAAQAAAAEAAAAXAw==</value>
</SonyCommands>
<SonyCommands>
<name>SubTitle</name>
<value>AAAAAgAAAJcAAAAoAw==</value>
</SonyCommands>
<SonyCommands>
<name>Yellow</name>
<value>AAAAAgAAAJcAAAAnAw==</value>
</SonyCommands>
<SonyCommands>
<name>Blue</name>
<value>AAAAAgAAAJcAAAAkAw==</value>
</SonyCommands>
<SonyCommands>
<name>Red</name>
<value>AAAAAgAAAJcAAAAlAw==</value>
</SonyCommands>
<SonyCommands>
<name>Green</name>
<value>AAAAAgAAAJcAAAAmAw==</value>
</SonyCommands>
<SonyCommands>
<name>Play</name>
<value>AAAAAgAAAJcAAAAaAw==</value>
</SonyCommands>
<SonyCommands>
<name>Stop</name>
<value>AAAAAgAAAJcAAAAYAw==</value>
</SonyCommands>
<SonyCommands>
<name>Pause</name>
<value>AAAAAgAAAJcAAAAZAw==</value>
</SonyCommands>
<SonyCommands>
<name>Rewind</name>
<value>AAAAAgAAAJcAAAAbAw==</value>
</SonyCommands>
<SonyCommands>
<name>Forward</name>
<value>AAAAAgAAAJcAAAAcAw==</value>
</SonyCommands>
<SonyCommands>
<name>Prev</name>
<value>AAAAAgAAAJcAAAA8Aw==</value>
</SonyCommands>
<SonyCommands>
<name>Next</name>
<value>AAAAAgAAAJcAAAA9Aw==</value>
</SonyCommands>
<SonyCommands>
<name>Replay</name>
<value>AAAAAgAAAJcAAAB5Aw==</value>
</SonyCommands>
<SonyCommands>
<name>Advance</name>
<value>AAAAAgAAAJcAAAB4Aw==</value>
</SonyCommands>
<SonyCommands>
<name>TopMenu</name>
<value>AAAAAgAAABoAAABgAw==</value>
</SonyCommands>
<SonyCommands>
<name>PopUpMenu</name>
<value>AAAAAgAAABoAAABhAw==</value>
</SonyCommands>
<SonyCommands>
<name>Eject</name>
<value>AAAAAgAAAJcAAABIAw==</value>
</SonyCommands>
<SonyCommands>
<name>Rec</name>
<value>AAAAAgAAAJcAAAAgAw==</value>
</SonyCommands>
<SonyCommands>
<name>SyncMenu</name>
<value>AAAAAgAAABoAAABYAw==</value>
</SonyCommands>
<SonyCommands>
<name>ClosedCaption</name>
<value>AAAAAgAAAKQAAAAQAw==</value>
</SonyCommands>
<SonyCommands>
<name>Teletext</name>
<value>AAAAAQAAAAEAAAA/Aw==</value>
</SonyCommands>
<SonyCommands>
<name>ChannelUp</name>
<value>AAAAAQAAAAEAAAAQAw==</value>
</SonyCommands>
<SonyCommands>
<name>ChannelDown</name>
<value>AAAAAQAAAAEAAAARAw==</value>
</SonyCommands>
<SonyCommands>
<name>Input</name>
<value>AAAAAQAAAAEAAAAlAw==</value>
</SonyCommands>
<SonyCommands>
<name>GGuide</name>
<value>AAAAAQAAAAEAAAAOAw==</value>
</SonyCommands>
<SonyCommands>
<name>EPG</name>
<value>AAAAAgAAAKQAAABbAw==</value>
</SonyCommands>
<SonyCommands>
<name>DOT</name>
<value>AAAAAgAAAJcAAAAdAw==</value>
</SonyCommands>
<SonyCommands>
<name>Analog</name>
<value>AAAAAgAAAHcAAAANAw==</value>
</SonyCommands>
<SonyCommands>
<name>Exit</name>
<value>AAAAAQAAAAEAAABjAw==</value>
</SonyCommands>
<SonyCommands>
<name>Digital</name>
<value>AAAAAgAAAJcAAAAyAw==</value>
</SonyCommands>
<SonyCommands>
<name>BS</name>
<value>AAAAAgAAAJcAAAAsAw==</value>
</SonyCommands>
<SonyCommands>
<name>CS</name>
<value>AAAAAgAAAJcAAAArAw==</value>
</SonyCommands>
<SonyCommands>
<name>BSCS</name>
<value>AAAAAgAAAJcAAAAQAw==</value>
</SonyCommands>
<SonyCommands>
<name>Ddata</name>
<value>AAAAAgAAAJcAAAAVAw==</value>
</SonyCommands>
<SonyCommands>
<name>InternetWidgets</name>
<value>AAAAAgAAABoAAAB6Aw==</value>
</SonyCommands>
<SonyCommands>
<name>InternetVideo</name>
<value>AAAAAgAAABoAAAB5Aw==</value>
</SonyCommands>
<SonyCommands>
<name>SceneSelect</name>
<value>AAAAAgAAABoAAAB4Aw==</value>
</SonyCommands>
<SonyCommands>
<name>Mode3D</name>
<value>AAAAAgAAAHcAAABNAw==</value>
</SonyCommands>
<SonyCommands>
<name>iManual</name>
<value>AAAAAgAAABoAAAB7Aw==</value>
</SonyCommands>
<SonyCommands>
<name>Wide</name>
<value>AAAAAgAAAKQAAAA9Aw==</value>
</SonyCommands>
<SonyCommands>
<name>Jump</name>
<value>AAAAAQAAAAEAAAA7Aw==</value>
</SonyCommands>
<SonyCommands>
<name>PAP</name>
<value>AAAAAgAAAKQAAAB3Aw==</value>
</SonyCommands>
<SonyCommands>
<name>MyEPG</name>
<value>AAAAAgAAAHcAAABrAw==</value>
</SonyCommands>
<SonyCommands>
<name>ProgramDescription</name>
<value>AAAAAgAAAJcAAAAWAw==</value>
</SonyCommands>
<SonyCommands>
<name>WriteChapter</name>
<value>AAAAAgAAAHcAAABsAw==</value>
</SonyCommands>
<SonyCommands>
<name>TrackID</name>
<value>AAAAAgAAABoAAAB+Aw==</value>
</SonyCommands>
<SonyCommands>
<name>TenKey</name>
<value>AAAAAgAAAJcAAAAMAw==</value>
</SonyCommands>
<SonyCommands>
<name>AppliCast</name>
<value>AAAAAgAAABoAAABvAw==</value>
</SonyCommands>
<SonyCommands>
<name>acTVila</name>
<value>AAAAAgAAABoAAAByAw==</value>
</SonyCommands>
<SonyCommands>
<name>DeleteVideo</name>
<value>AAAAAgAAAHcAAAAfAw==</value>
</SonyCommands>
<SonyCommands>
<name>EasyStartUp</name>
<value>AAAAAgAAAHcAAABqAw==</value>
</SonyCommands>
<SonyCommands>
<name>OneTouchTimeRec</name>
<value>AAAAAgAAABoAAABkAw==</value>
</SonyCommands>
<SonyCommands>
<name>OneTouchView</name>
<value>AAAAAgAAABoAAABlAw==</value>
</SonyCommands>
<SonyCommands>
<name>OneTouchRec</name>
<value>AAAAAgAAABoAAABiAw==</value>
</SonyCommands>
<SonyCommands>
<name>OneTouchRecStop</name>
<value>AAAAAgAAABoAAABjAw==</value>
</SonyCommands>
<SonyCommands>
<name>MuteOn</name>
<value>http://192.168.0.15:80/cers/command/MuteOn</value>
</SonyCommands>
<SonyCommands>
<name>MuteOff</name>
<value>http://192.168.0.15:80/cers/command/MuteOff</value>
</SonyCommands>
</Commands>
<Server_Macaddress>6C-62-6D-EA-62-6C</Server_Macaddress>
<Server_Name>CCSG(SonyAPILib)</Server_Name>
<Registered>true</Registered>
<Actionlist_Url>http://192.168.0.15:80/cers/ActionList.xml</Actionlist_Url>
<DocumentURL>http://192.168.0.15:52323/dmr.xml</DocumentURL>
</SonyDevice>