static void Main(string[] args) { SonyAPI_Lib mySonyLib = new SonyAPI_Lib(); // Create an Instance of the Library mySonyLib.LOG.enableLogging = false; // Set to NO logging SonyAPI_Lib.SonyDevice mySonyDev = new SonyAPI_Lib.SonyDevice(); // Create a new instance of a Device Object // Now there are 2 ways you can complete the next part. // You can build the Device from the Device's Description Document // Like This: //mySonyDev.buildFromDocument(new Uri("http://192.168.0.100:52323/dmr.xml")); //Or, if you have created a Device File, then you can load and use it. //This is the prefered method, as it would be the fastest. //Like This: mySonyDev = mySonyLib.Locator.DeviceLoad(@"c:\MyDevices\Bravia55.xml"); string cmd = mySonyDev.getIRCCcommandString("VolumeUp"); //Get the Command String value string results = mySonyLib.ircc1.XSendIRCC(mySonyDev, cmd); //Send Command Value to device using the IRCC:1 Service }
/// <summary> /// Executes the XGetOperationList action. /// </summary> /// <param name="parent">The Device object to execute the request on</param> /// <returns>Out value for the OperationList action parameter.</returns> public String XGetOperationList(SonyAPI_Lib.SonyDevice parent) { // object[] loIn = new object[1]; // loIn[0] = aVTInstanceID; // object[] loOut = InvokeAction(csAction_XGetOperationList, loIn); return ""; }
/// <summary> /// Executes the XExecuteOperation action. /// </summary> /// <param name="parent">The Device object to execute the request on</param> /// <param name="actionDirective">In value for the ActionDirective action parameter.</param> /// <returns>Out value for the Result action parameter.</returns> public String XExecuteOperation(SonyAPI_Lib.SonyDevice parent, String actionDirective) { // object[] loIn = new object[2]; // loIn[0] = aVTInstanceID; // loIn[1] = actionDirective; // object[] loOut = InvokeAction(csAction_XExecuteOperation, loIn); return ""; }
/// <summary> /// Executes the SetPlayMode action. /// </summary> /// <param name="parent">The Device object to execute the request on</param> /// <param name="newPlayMode">In value for the NewPlayMode action parameter. Default value of NORMAL.</param> public void SetPlayMode(SonyAPI_Lib.SonyDevice parent, CurrentPlayModeEnum newPlayMode) { // object[] loIn = new object[2]; // loIn[0] = instanceID; // loIn[1] = ToStringCurrentPlayMode(newPlayMode); // InvokeAction(csAction_SetPlayMode, loIn); }
/// <summary> /// Executes the Seek action. /// </summary> /// <param name="parent">The Device object to execute the request on</param> /// <param name="unit">In value for the Unit action parameter.</param> /// <param name="target">In value for the Target action parameter.</param> public void Seek(SonyAPI_Lib.SonyDevice parent, int unit, String target) { // object[] loIn = new object[3]; // loIn[0] = instanceID; // loIn[1] = ToStringAARGTYPESeekMode(unit); // loIn[2] = target; // InvokeAction(csAction_Seek, loIn); }
/// <summary> /// Executes the Previous action. /// </summary> /// <param name="parent">The Device object to execute the request on</param> public void Previous(SonyAPI_Lib.SonyDevice parent) { // object[] loIn = new object[1]; // loIn[0] = instanceID; // InvokeAction(csAction_Previous, loIn); }
/// <summary> /// Executes the XExit action. /// </summary> /// <param name="parent">The Device object to execute the request on</param> /// <param name="listenerSessionID">In value for the ListenerSessionID action parameter.</param> public void XExit(SonyAPI_Lib.SonyDevice parent, UInt32 listenerSessionID) { // object[] loIn = new object[1]; // loIn[0] = listenerSessionID; // InvokeAction(csAction_XExit, loIn); }
static void Main(string[] args) { // 1st we create a new instance of the SonyAPILib SonyAPI_Lib mySonyLib = new SonyAPI_Lib(); #region No parameters if (args.Length < 1) { Console.WriteLine("ERROR: Missing parameters...."); showhelp(); } #endregion #region Logging if (args[args.Length - 1] == "/log") { mySonyLib.LOG.enableLogging = true; mySonyLib.LOG.enableLogginglev = "All"; } #endregion #region /h and /? Help and Individual Help if (args[0] == "/h" | args[0] == "/?") { showhelp(); } if (args.Length > 1) { if (args[1] == "/?") { showcommandhelp(args[0]); } } #endregion #region WOL - Wake-On-Lan if (args[0] == "/WOL") { SonyAPI_Lib.SonyDevice device = mySonyLib.Locator.DeviceLoad(args[1]); device.WOL(); } #endregion #region /b - Build From Document else if (args[0] == "/b") { try { string du = args[1]; string pa = args[2] + @"\"; SonyAPI_Lib.SonyDevice nDev = new SonyAPI_Lib.SonyDevice(); nDev.buildFromDocument(new Uri(du)); pa = pa + nDev.Name + ".xml"; Console.WriteLine("Saving Device: " + nDev.Name + ".xml to " + pa); mySonyLib.Locator.DeviceSave(pa, nDev); } catch { Console.WriteLine("ERROR: Incorrect parameters...."); showhelp(); } } #endregion #region /l and /ls - Locate and Locate Save else if (args[0] == "/l" | args[0] == "/ls") { try { Console.WriteLine("Locating Devices. Please wait........."); List<string> fdev = mySonyLib.Locator.locateDevices(); Console.WriteLine("Devices Found: " + fdev.Count); if (fdev.Count > 0) { int i = 1; foreach (string d in fdev) { Console.WriteLine(i + ") " + d); i = i + 1; } } else { Console.WriteLine("NO Devices Found"); System.Environment.Exit(0); } if (args[0] == "/ls") { foreach (string dv in fdev) { string pa = args[2] + @"\"; SonyAPI_Lib.SonyDevice nDev = new SonyAPI_Lib.SonyDevice(); nDev.buildFromDocument(new Uri(dv)); pa = pa + nDev.Name + ".xml"; Console.WriteLine("Saving Device: " + nDev.Name + ".xml to " + pa); mySonyLib.Locator.DeviceSave(pa, nDev); } } } catch { Console.WriteLine("ERROR: Incorrect parameters...."); showhelp(); } } #endregion #region /r - Register else if (args[0] == "/r") { if (args.Length > 1) { string devFile = ""; devFile = args[1]; SonyAPI_Lib.SonyDevice device = mySonyLib.Locator.DeviceLoad(devFile); bool mySonyReg = false; if (device.Registered == false) { Console.WriteLine(device.Name + ": Performing Registration...."); Console.WriteLine("Before continuing, you may need to set the device to Registration Mode,"); Console.WriteLine("Confirm Registration or enter the Registration PIN code."); Console.WriteLine("Go to the device and perfrom any step, or be ready to before hitting enter below!"); Console.WriteLine("====================================="); Console.WriteLine("Hit enter to Continue...."); string c = Console.ReadLine(); mySonyReg = device.register(); if (device.Registered == false) { if (device.Actionlist.RegisterMode == 3) { string ckii; Console.WriteLine("Enter PIN Code."); ckii = Console.ReadLine(); Console.WriteLine("Sending Authitication PIN Code."); mySonyReg = device.sendAuth(ckii); } } } else { mySonyReg = true; } mySonyLib.Locator.DeviceSave(devFile, device); } else { Console.WriteLine("ERROR: missing parameters...."); showhelp(); } } #endregion #region /a - Action else if (args[0] == "/a") { if (args.Length > 4) { string devFile = ""; string devService = ""; string devAction = ""; string devP = ""; devFile = args[1]; devService = args[2]; devAction = args[3]; devP = args[4]; SonyAPI_Lib.SonyDevice device = mySonyLib.Locator.DeviceLoad(devFile); if (devService == "IRCC") { if (devAction == "XSendIRCC") { mySonyLib.ircc1.XSendIRCC(device, devP); } } else if (devService == "AVTransport") { } else if (devService == "ConnectionManager") { } else if (devService == "RenderingControl") { if (devAction == "SetMute") { Boolean p1 = false; if (devP == "true" | devP == "True") { p1 = true; } mySonyLib.renderingcontrol1.SetMute(device, p1); } if (devAction == "SetVolume") { int p1 = 0; p1 = Convert.ToInt32(devP); mySonyLib.renderingcontrol1.SetVolume(device, p1); } } else if (devService == "Party") { } } else { Console.WriteLine("ERROR: missing parameters...."); showhelp(); } } #endregion }
/// <summary> /// Executes the SelectPreset action. /// </summary> /// <param name="parent">The Device object to execute the request on</param> /// <param name="presetName">In value for the PresetName action parameter.</param> public void SelectPreset(SonyAPI_Lib.SonyDevice parent, string presetName) { // object[] loIn = new object[2]; // loIn[0] = instanceID; // loIn[1] = ToStringAARGTYPEPresetName(presetName); // InvokeAction(csAction_SelectPreset, loIn); }
/// <summary> /// Executes the XStart action. /// </summary> /// <param name="parent">The Device object to execute the request on</param> /// <param name="partyMode">In value for the PartyMode action parameter.</param> /// <param name="listenerList">In value for the ListenerList action parameter.</param> /// <returns>Out value for the SingerSessionID action parameter.</returns> public UInt32 XStart(SonyAPI_Lib.SonyDevice parent, String partyMode, String listenerList) { // object[] loIn = new object[2]; // loIn[0] = partyMode; // loIn[1] = listenerList; // object[] loOut = InvokeAction(csAction_XStart, loIn); return 0; }
/// <summary> /// Executes the XLeave action. /// </summary> /// <param name="parent">The Device object to execute the request on</param> /// <param name="singerSessionID">In value for the SingerSessionID action parameter.</param> /// <param name="listenerList">In value for the ListenerList action parameter.</param> public void XLeave(SonyAPI_Lib.SonyDevice parent, UInt32 singerSessionID, String listenerList) { // object[] loIn = new object[2]; // loIn[0] = singerSessionID; // loIn[1] = listenerList; // InvokeAction(csAction_XLeave, loIn); }
/// <summary> /// Executes the XInvite action. /// </summary> /// <param name="parent">The Device object to execute the request on</param> /// <param name="partyMode">In value for the PartyMode action parameter.</param> /// <param name="singerUUID">In value for the SingerUUID action parameter.</param> /// <param name="singerSessionID">In value for the SingerSessionID action parameter.</param> /// <returns>Out value for the ListenerSessionID action parameter.</returns> public UInt32 XInvite(SonyAPI_Lib.SonyDevice parent, String partyMode, String singerUUID, UInt32 singerSessionID) { // object[] loIn = new object[3]; // loIn[0] = partyMode; // loIn[1] = singerUUID; // loIn[2] = singerSessionID; // object[] loOut = InvokeAction(csAction_XInvite, loIn); return 0; }
/// <summary> /// Executes the XGetState action. /// </summary> /// <param name="parent">The Device object to execute the request on</param> /// <remarks>Populates the Following State Variables: Party State, Party Mode, Party Song, Session ID, Number of Listeners, Listener List, Singer UUID and Singer Session ID</remarks> public void XGetState(SonyAPI_Lib.SonyDevice parent) { // object[] loIn = new object[0]; // object[] loOut = InvokeAction(csAction_XGetState, loIn); // partyState = (String)loOut[0]; // partyMode = (String)loOut[1]; // partySong = (String)loOut[2]; // sessionID = (UInt32)loOut[3]; // numberOfListeners = (Byte)loOut[4]; // listenerList = (String)loOut[5]; // singerUUID = (String)loOut[6]; // singerSessionID = (UInt32)loOut[7]; }
/// <summary> /// Executes the XGetDeviceInfo action. /// </summary> /// <param name="parent">The Device object to execute the request on</param> /// <remarks>Populates the following State Variables: Singer Capability and Transport Port</remarks> public void XGetDeviceInfo(SonyAPI_Lib.SonyDevice parent) { // object[] loIn = new object[0]; // object[] loOut = InvokeAction(csAction_XGetDeviceInfo, loIn); // singerCapability = (Byte)loOut[0]; // transportPort = (UInt16)loOut[1]; }
static void Main(string[] args) { Console.WriteLine("SonyAPILib v5.2 by: Kirk Herron"); Console.WriteLine("Starting Console Example Program"); Console.WriteLine("================================"); // 1st we create a new instance of the SonyAPILib SonyAPI_Lib mySonyLib = new SonyAPI_Lib(); // Now create new instances of the UPnP/DLNA services //SonyAPI_Lib.IRCC1 ircc1 = new SonyAPI_Lib.IRCC1(); // Only required if you plan to use this service //SonyAPI_Lib.AVTransport1 avtransport1 = new SonyAPI_Lib.AVTransport1(); // Only required if you plan to use this service //SonyAPI_Lib.ConnectionManager1 connectionmanager1 = new SonyAPI_Lib.ConnectionManager1(); // Only required if you plan to use this service //SonyAPI_Lib.RenderingControl1 renderingcontrol1 = new SonyAPI_Lib.RenderingControl1(); // Only required if you plan to use this service //SonyAPI_Lib.Party1 party1 = new SonyAPI_Lib.Party1(); // Only required if you plan to use this service #region Set Logging // Next Set the API logging information. // Enable Logging: default is set to FALSE. mySonyLib.LOG.enableLogging = true; // Set Logging Level. // Set to "Basic" to only Log Minimum information // Set to "All" for all Logging information // Default is set to "Basic" mySonyLib.LOG.enableLogginglev = "All"; // Set where the logging file will be saved. // Folder will be created if it does not exist! // Set to Null to use Default // Default is set to C:\ProgramData\Sony mySonyLib.LOG.loggingPath = null; // Set the name of the Logging file. // Default is set to SonyAPILib_LOG.txt mySonyLib.LOG.loggingName = "SonyAPILib_LOG.txt"; // Clears the existing log file and starts a new one // Send Null as the param to just clear the file and start a new one // Enter a new File name as the param, and log file will be copied to new name before it is cleared. // Example: mySonyLib.LOG.clearlog(datestamp + "_Old_Sony_Log_File.txt"); mySonyLib.LOG.clearLog(null); #endregion #region Device Locator // Perform a Discovery to find all/any compatiable devices on the LAN. // Returns a list of all Devices found through the UPnP Broadcast // Return value is a list containg the Description.xml file for each Device object discovered. // Each returned object will contain the full URL to the devices Description.xml file Console.WriteLine("Searching for Devices..."); List<string> foundDevices = mySonyLib.Locator.locateDevices(); #endregion // foundDevices.Count will return the number of devices found #region Console Output Console.WriteLine("Device Count: " + foundDevices.Count); Console.WriteLine("---------------------------------"); int i = 0; foreach (string fd in foundDevices) { Console.WriteLine(i + " - " + fd.ToString()); i = i + 1; } Console.WriteLine("---------------------------------"); #endregion // TODO: Here you can perform task or other code as to which device to select or use. // You could also do a For Next loop and go through each one. // Or save the Description.xml URL for later use! // This example makes sure that there is at least one object returned in the list, if not then it will Exit. if (foundDevices.Count > 0) { // Allow User to select from the devices found which one to test Console.WriteLine("Enter the Device # to Test"); string cki; cki = Console.ReadLine(); // 1st create a new Device Object SonyAPI_Lib.SonyDevice mySonyDevice = new SonyAPI_Lib.SonyDevice(); // Here you can save the device information to a database or text file. // This will allow you to Initialize a device WITHOUT having to run the sonyDiscover() method every time. // Once you have discovered the devices, saving their information will speed up your application the next time you run it! // You can Initialize a device with only the following minimimal information: // 1) The Device Name - MUST Match what the device returns as it's name. (selDev.Name) // 2) The IP address of the device. (selDev.Device_IP_Address) // Now we build the new sonyDevice object with the selected device above. #region Build Device from Description.xml file // The buildFromDocument() method will retrieve the devices Description file, and build/populate the device object. // From above, selDev or each item in the list foundDevices[] is a SonyDevice object. // To build the device with the default information retrieved from locateDevices, use the following method: // mySonyDevice.DocumentURL = foundDevices[0].ToString(); or set the array to the device you want. // mySonyDevice.buildFromDocument(new Uri(mySonyDevice.DocumentURL)); // This example will use the first method to initialize the device chosen by the user. Console.WriteLine(""); Console.WriteLine(foundDevices[Convert.ToInt16(cki)].ToString() + ": Building Device...."); // Set the devices DocumentUrl property first mySonyDevice.DocumentURL = foundDevices[Convert.ToInt16(cki)].ToString(); // Then build the device from the document mySonyDevice.buildFromDocument(new Uri(mySonyDevice.DocumentURL)); #endregion // Next we will check the status of the device. #region Check Status //The following will return the current status of the device //The value returned is: status_name:value //An example would be: viewing:TV //An emplty string "" will be returned if there is no response from the device. This could also mean the device is off. //Also, this method requires the device to be registered on Generation 1 and 2 devices. Console.WriteLine(mySonyDevice.Name + ": Checking Device Status...."); // Without a response: mySonyLib.ircc1.XGetStatus(mySonyDevice); string status = mySonyLib.ircc1.XGetStatus(mySonyDevice); // Use the Device State Variable: if (mySonyDevice.IRCC.sv_CurrentStatus == "" | mySonyDevice.IRCC.sv_CurrentStatus == null) if (status == "" | status == null) { // NO Response!! } else { #region Console Output Console.WriteLine(""); Console.WriteLine("Get Status returned: " + status); Console.WriteLine("---------------------------------"); Console.WriteLine(""); #endregion } #endregion // Now we must register with the device #region register bool mySonyReg = false; // first check to see if the Build process determined the registration value. if (mySonyDevice.Registered == false) { Console.WriteLine(mySonyDevice.Name + ": Performing Registration...."); Console.WriteLine("Before continuing, you may need to set the device to Registration Mode,"); Console.WriteLine("Confirm Registration or enter the Registration PIN code."); Console.WriteLine("Go to the device and perfrom any step, or be ready to before ehitting enter below!"); Console.WriteLine("====================================="); Console.WriteLine("Hit any key to continue"); Console.ReadKey(); // The next method is very IMPORTANT. // YOU MUST RUN THE FOLLOWING METHOD AND RECEIVE A SUCCESSFUL RETURN at least ONCE! // Before you can send any IRCC commands or receive and data back from the device! // The very first time this is executed, you will need to be at your device (TV, Blue Ray) // to confim the registration. Also, some devices (Blue Ray, Home Theater Tuners) require you to put // the device in to "Registration" mode, before you try to register this application as // a controlling device. (Registration uses the MAC address of the computer/device trying //to gain control). If installed on more than 1 computer, each one will require registration. // Register as Controller // Returns true if successful // Returns false if not successful mySonyReg = mySonyDevice.register(); // Check if register returned false if (mySonyDevice.Registered == false) { //Check if Generaton 3. If yes, prompt for pin code if (mySonyDevice.Actionlist.RegisterMode == 3) { string ckii; Console.WriteLine("Enter PIN Code."); ckii = Console.ReadLine(); // Send PIN code to TV to create Autorization cookie Console.WriteLine("Sending Authitication PIN Code."); mySonyReg = mySonyDevice.sendAuth(ckii); } } } else { mySonyReg = true; } #endregion //TODO: Add more code in case of false, or true #region Console Output Console.WriteLine("Registration returned: " + mySonyReg.ToString()); Console.WriteLine("---------------------------------"); Console.WriteLine(""); #endregion // This example will: If true, display device information #region Console Output if (mySonyReg) { Console.WriteLine("Device Information"); Console.WriteLine("Mame: " + mySonyDevice.Name); Console.WriteLine("Mac Address: " + mySonyDevice.Device_Macaddress); Console.WriteLine("IP Address: " + mySonyDevice.Device_IP_Address); Console.WriteLine("Port: " + mySonyDevice.Device_Port); Console.WriteLine("Registration Mode: " + mySonyDevice.Actionlist.RegisterMode); Console.WriteLine("Registration: " + mySonyDevice.Registered.ToString()); Console.WriteLine("Server Name: " + mySonyDevice.Server_Name); Console.WriteLine("Server Mac: " + mySonyDevice.Server_Macaddress); Console.WriteLine("Action List URL: " + mySonyDevice.Actionlist_Url); Console.WriteLine("---------------------------------"); Console.WriteLine(""); } else { // Display this if NOT true Console.WriteLine("There was an error"); Console.WriteLine("---------------------------------"); Console.WriteLine(""); } #endregion // Get the IRCC command list from the device so we know it's capabilities. #region get_remote_command_list // The next command is used to retrieve the IRCC command list from the device. // ### You must register before this method will return any data ### // This method will populate the Commands list in the SonyDevice object when executed. // This Methed also returnes a string that contains the contents of the Devices Command List XML file for your own use. Console.WriteLine(mySonyDevice.Name + ": Retrieving Remote Command List"); string CmdList = mySonyDevice.get_remote_command_list(); // TODO: Parse this information as your application requires. // convert to an XMLDocument or dataset for your own use #endregion // Checks if the list contains any data #region Console Output if (CmdList != "") { Console.WriteLine("Retrieved Command List Successful"); Console.WriteLine("---------------------------------"); Console.WriteLine(""); } else { Console.WriteLine("ERROR Retrieving Command List"); Console.WriteLine("---------------------------------"); Console.WriteLine(""); } #endregion // Get the IRCC command value by searching the command name #region getIRCCcommandString // The next method is used to search for an IRCC_Command that matches the param. // param is a string containing the command name to search for. // Returns a string containing the command's value (If Successful) // Returna a Null if the search command is not found in the devices IRCC command list // This example will search for the command "ChannelUp" Console.WriteLine(mySonyDevice.Name + ": Retrieving Command Value for: VolumeUp"); string irccCmd = mySonyDevice.getIRCCcommandString("VolumeUp"); //Check if command was found if (irccCmd == "") { Console.WriteLine("Command Not Found: VolumeUp"); } else { #endregion // Displays the IRCC command value retrieved #region Console Output // Show the IRCC_Command value found information Console.WriteLine("Found Command: VolumeUp"); Console.WriteLine("Command Value: " + irccCmd); Console.WriteLine("---------------------------------"); Console.WriteLine(""); Console.WriteLine("Now we are ready to try to send a few IRCC commands to the device"); Console.WriteLine("Hit any key to continue"); Console.ReadKey(); } #endregion // Next are 4 examples of how you can send the IRCC commands to the device #region Example 1 // This first example will send a "VolumeUp" command value to the device // it asumes we already know the value to send to the device. // We will use the irccCmd we retrieved above in the getIRCCCommandString method. Console.WriteLine(mySonyDevice.Name + ": Sending Command Value " + irccCmd + " to device"); //renderingcontrol1.SetMute(mySonyDevice, true); //renderingcontrol1.SetMute(mySonyDevice, false); //connectionmanager1.GetProtocolInfo(mySonyDevice); string results = mySonyLib.ircc1.XSendIRCC(mySonyDevice,irccCmd); System.Threading.Thread.Sleep(500); // give the device time to react before sending another command #region Console Output // Show the IRCC_Command value found information Console.WriteLine("Sent Command: VolumeUp:" + irccCmd); Console.WriteLine("Hit any key to continue"); Console.WriteLine("---------------------------------"); Console.ReadKey(); #endregion #endregion #region Example 2 // The next example will use the getIRCCcommandString("CommandName") method to get the command value for "VolumeDown". // Then send it to the device Console.WriteLine(mySonyDevice.Name + ": Sending Command VolumeDown to device"); String mycommand = mySonyDevice.getIRCCcommandString("VolumeDown"); results = mySonyLib.ircc1.XSendIRCC(mySonyDevice,mycommand); System.Threading.Thread.Sleep(500); // give the device time to react before sending another command #region Console Output // Show the IRCC_Command value found information Console.WriteLine("Sent Command: VolumeDown:" + mycommand); Console.WriteLine("Hit any key to continue"); Console.WriteLine("---------------------------------"); Console.ReadKey(); #endregion #endregion #region Example 3 // The next example will use a combination of both examples above for the command "VolumeUp". Console.WriteLine(mySonyDevice.Name + ": Sending Command VolumeUp to device again"); mySonyLib.ircc1.XSendIRCC(mySonyDevice, mySonyDevice.getIRCCcommandString("VolumeUp")); System.Threading.Thread.Sleep(500); // give the device time to react before sending another command #region Console Output // Show the IRCC_Command value found information Console.WriteLine("Sent Command: VolumeUp:" + mycommand); Console.WriteLine("Hit any key to continue"); Console.WriteLine("---------------------------------"); Console.ReadKey(); #endregion #endregion #region Example 5 Console.WriteLine(""); Console.WriteLine("Now You Try."); Console.WriteLine("Here are the Commands: Hit any key to Continue."); Console.WriteLine("---------------------------------"); Console.ReadKey(); foreach (SonyAPI_Lib.SonyCommands cmd in mySonyDevice.Commands) { Console.WriteLine(cmd.name); } Console.WriteLine("---------------------------------"); Console.WriteLine("Enter a command from the list above."); cki = Console.ReadLine(); results = mySonyLib.ircc1.XSendIRCC(mySonyDevice, mySonyDevice.getIRCCcommandString(cki)); #endregion #region Example 6 Console.WriteLine("---------------------------------"); Console.WriteLine("Now, using your TV remote control, navigate to a search screen."); Console.WriteLine("This can be Pandora, Youtube or any search where you enter TEXT."); Console.WriteLine("Now, enter the text here to send."); cki = Console.ReadLine(); results = mySonyDevice.send_text(cki); Console.WriteLine("---------------------------------"); #endregion Console.WriteLine("That's about it for now. Hit enter to Quit."); Console.ReadKey(); } else { Console.WriteLine("Error: No Devices were found!"); Console.ReadKey(); } }
/// <summary> /// Executes the GetCurrentTransportActions action. /// </summary> /// <param name="parent">The Device object to execute the request on</param> /// <returns>Out value for the Actions action parameter.</returns> public String GetCurrentTransportActions(SonyAPI_Lib.SonyDevice parent) { // object[] loIn = new object[1]; // loIn[0] = instanceID; // object[] loOut = InvokeAction(csAction_GetCurrentTransportActions, loIn); return""; }
/// <summary> /// Executes the GetTransportSettings action. /// </summary> /// <param name="parent">The Parent Device object to execute this action on.</param> /// <remarks>Populates the following State Variables: Current Play Mode, Record Quality Mode</remarks> public void GetTransportSettings(SonyAPI_Lib.SonyDevice parent) { if (parent.AVTransport.controlURL != null) { string XMLHead = "<?xml version=\"1.0\"?>" + Environment.NewLine + "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" + Environment.NewLine + "<SOAP-ENV:Body>" + Environment.NewLine; string XMLFoot = "</SOAP-ENV:Body>" + Environment.NewLine + "</SOAP-ENV:Envelope>" + Environment.NewLine; string XML = XMLHead + "<m:GetTransportSettings xmlns:m=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID xmlns:dt=\"urn:schemas-microsoft-com:datatypes\" dt:dt=\"ui4\">" + InstanceID + "</InstanceID></m:GetTransportSettings>" + XMLFoot + Environment.NewLine; Socket SocWeb = HelperDLNA.MakeSocket(parent.Device_IP_Address, parent.Device_Port); int reqi = parent.AVTransport.controlURL.IndexOf(":") + 3; string req = parent.AVTransport.controlURL.Substring(reqi); reqi = parent.AVTransport.controlURL.IndexOf(":") + 1; req = req.Substring(reqi); reqi = req.IndexOf("/") + 1; req = req.Substring(reqi); string Request = HelperDLNA.MakeRequest("POST", req, XML.Length, "urn:schemas-upnp-org:service:AVTransport:1#GetTransportSettings", parent.Device_IP_Address, parent.Device_Port) + XML; SocWeb.Send(UTF8Encoding.UTF8.GetBytes(Request), SocketFlags.None); string GG = HelperDLNA.ReadSocket(SocWeb, true, ref this.ReturnCode); GG = Extentions.ChopOffBefore(GG, "<?xml"); GG = "<?xml" + GG; XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(GG); XmlNode xNode = xDoc.DocumentElement.ChildNodes[0]; foreach (XmlNode node in xNode.ChildNodes) { foreach (XmlNode snode in node.ChildNodes) { if (snode.Name == "PlayMode") { parent.AVTransport.sv_CurrentPlayMode = snode.InnerText; } if (snode.Name == "RecQualityModes") { parent.AVTransport.sv_PossibleRecordQualityModes = snode.InnerText; } } } parent.AVTransport.sv_LastChange = "GetTransportSettings"; } }
private void showDevice(SonyAPI_Lib.SonyDevice cDev) { devName.Text = cDev.Name; devIP.Text = cDev.Device_IP_Address; devPort.Text = cDev.Device_Port.ToString(); devMac.Text = cDev.Device_Macaddress; devGen.Text = cDev.Actionlist.RegisterMode.ToString(); devCommands.Text = cDev.Commands.Count().ToString(); devSName.Text = cDev.Server_Name; devSMac.Text = cDev.Server_Macaddress; devReg.Text = cDev.Registered.ToString(); Commands.DataSource = cDev.Commands; Commands.DisplayMember = "Name"; Commands.ValueMember = "Name"; string hCH = curDev.getIRCCcommandString("ChannelUp"); if (hCH != "") { devType = "TV"; pictureBox1.Image = Sony_Forms_Example.Properties.Resources.TV_icon1; ChanUp.Visible = true; ChanDown.Visible = true; Chanlabel.Visible = true; Guide.Visible = true; Yellow.Visible = true; Red.Visible = true; Blue.Visible = true; Green.Visible = true; } else { devType = "other"; pictureBox1.Image = Sony_Forms_Example.Properties.Resources.Stereo_Icon; ChanUp.Visible = false; ChanDown.Visible = false; Chanlabel.Visible = false; Guide.Visible = false; Yellow.Visible = false; Red.Visible = false; Blue.Visible = false; Green.Visible = false; } if(curDev.Registered == true) { regButton.Visible = false; } else { regButton.Visible = true; } this.Refresh(); }
/// <summary> /// Executes the XAbort action. /// </summary> /// <param name="parent">The Device object to execute the request on</param> /// <param name="singerSessionID">In value for the SingerSessionID action parameter.</param> public void XAbort(SonyAPI_Lib.SonyDevice parent, UInt32 singerSessionID) { // object[] loIn = new object[1]; // loIn[0] = singerSessionID; // InvokeAction(csAction_XAbort, loIn); }