http/1.1 200 OKCACHE-CONTRol: max-age=1800EXT: LOCATION: http://192.168.1.11:52323/dmr.xmlSERVER: linux/2.6 UPnP/1.0 KDL-42W800A/1.7ST: urn:schemas-upnp-org:service:AVTransport:1USN: uuID:00000000-0000-1010-8000-d8d43c73618b::urn:schemas-upnp-org:service:AVTransport:1X-AV-Physical-Unit-Info: pa="BraviA KDL-42W800A";X-AV-Server-Info: av=5.0; cn="Sony Corporation"; mn="BraviA KDL-42W800A"; mv="1.7";
从这里我已经按照位置检索包含电视上更多细节的XML文件.给出如下:
<?xml version="1.0"?><root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:pnpx="http://schemas.microsoft.com/windows/pnpx/2005/11" xmlns:df="http://schemas.microsoft.com/windows/2008/09/devicefoundation"> <specVersion> <major>1</major> <minor>0</minor> </specVersion> <device> <deviceType>urn:schemas-upnp-org:device:MediaRenderer:1</deviceType> <frIEndlyname>BraviA KDL-42W800A</frIEndlyname> <manufacturer>Sony Corporation</manufacturer> <manufacturerURL>http://www.sony.net/</manufacturerURL> <modelname>KDL-42W800A</modelname> <modelNumber>MINT1.7.0.1</modelNumber> <UDN>uuID:00000000-0000-1010-8000-d8d43c73618b</UDN> <dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMR-1.50</dlna:X_DLNADOC> <microsoft:magicPacketWakeSupported xmlns:microsoft="urn:schemas-microsoft-com:WMPNSS-1-0">1</microsoft:magicPacketWakeSupported> <iconList> <icon> <mimetype>image/png</mimetype> <wIDth>32</wIDth> <height>32</height> <depth>24</depth> <url>/MediaRenderer_32x32.png</url> </icon> <icon> <mimetype>image/png</mimetype> <wIDth>48</wIDth> <height>48</height> <depth>24</depth> <url>/MediaRenderer_48x48.png</url> </icon> <icon> <mimetype>image/png</mimetype> <wIDth>60</wIDth> <height>60</height> <depth>24</depth> <url>/MediaRenderer_60x60.png</url> </icon> <icon> <mimetype>image/png</mimetype> <wIDth>120</wIDth> <height>120</height> <depth>24</depth> <url>/MediaRenderer_120x120.png</url> </icon> <icon> <mimetype>image/jpeg</mimetype> <wIDth>32</wIDth> <height>32</height> <depth>24</depth> <url>/MediaRenderer_32x32.jpg</url> </icon> <icon> <mimetype>image/jpeg</mimetype> <wIDth>48</wIDth> <height>48</height> <depth>24</depth> <url>/MediaRenderer_48x48.jpg</url> </icon> <icon> <mimetype>image/jpeg</mimetype> <wIDth>60</wIDth> <height>60</height> <depth>24</depth> <url>/MediaRenderer_60x60.jpg</url> </icon> <icon> <mimetype>image/jpeg</mimetype> <wIDth>120</wIDth> <height>120</height> <depth>24</depth> <url>/MediaRenderer_120x120.jpg</url> </icon> </iconList> <serviceList> <service> <serviceType>urn:schemas-upnp-org:service:RenderingControl:1</serviceType> <serviceID>urn:upnp-org:serviceID:RenderingControl</serviceID> <SCPDURL>/RenderingControlSCPD.xml</SCPDURL> <controlURL>/upnp/control/RenderingControl</controlURL> <eventSubURL>/upnp/event/RenderingControl</eventSubURL> </service> <service> <serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType> <serviceID>urn:upnp-org:serviceID:ConnectionManager</serviceID> <SCPDURL>/ConnectionManagerSCPD.xml</SCPDURL> <controlURL>/upnp/control/ConnectionManager</controlURL> <eventSubURL>/upnp/event/ConnectionManager</eventSubURL> </service> <service> <serviceType>urn:schemas-upnp-org:service:AVTransport:1</serviceType> <serviceID>urn:upnp-org:serviceID:AVTransport</serviceID> <SCPDURL>/AVTransportSCPD.xml</SCPDURL> <controlURL>/upnp/control/AVTransport</controlURL> <eventSubURL>/upnp/event/AVTransport</eventSubURL> </service> <service> <serviceType>urn:dial-multiscreen-org:service:dial:1</serviceType> <serviceID>urn:dial-multiscreen-org:serviceID:dial</serviceID> <SCPDURL>/DIALSCPD.xml</SCPDURL> <controlURL>/upnp/control/DIAL</controlURL> <eventSubURL></eventSubURL> </service> <service> <serviceType>urn:schemas-sony-com:service:IRCC:1</serviceType> <serviceID>urn:schemas-sony-com:serviceID:IRCC</serviceID> <SCPDURL>/IRCCSCPD.xml</SCPDURL> <controlURL>http://192.168.1.11/sony/IRCC</controlURL> <eventSubURL></eventSubURL> </service> <service> <serviceType>urn:schemas-sony-com:service:ScalarWebAPI:1</serviceType> <serviceID>urn:schemas-sony-com:serviceID:ScalarWebAPI</serviceID> <SCPDURL>/ScalarWebAPISCPD.xml</SCPDURL> <controlURL>/upnp/control/ScalaraPI</controlURL> <eventSubURL></eventSubURL> </service> </serviceList> <av:X_MaxBGMCount xmlns:av="urn:schemas-sony-com:av">64</av:X_MaxBGMCount> <av:X_StandardDMR xmlns:av="urn:schemas-sony-com:av">1.1</av:X_StandardDMR> <av:X_ScreenResolution xmlns:av="urn:schemas-sony-com:av">2K</av:X_ScreenResolution> <av:X_IRCCCodeList xmlns:av="urn:schemas-sony-com:av"> <av:X_IRCCCode command="Power">AAAAAQAAAAEAAAAVAw==</av:X_IRCCCode> <av:X_IRCCCode command="Power ON">AAAAAQAAAAEAAAAuAw==</av:X_IRCCCode> <av:X_IRCCCode command="Power OFF">AAAAAQAAAAEAAAAvAw==</av:X_IRCCCode> </av:X_IRCCCodeList> <pnpx:X_compatibleID>MS_DigitalMediaDeviceClass_DMR_V001</pnpx:X_compatibleID> <pnpx:X_devicecategory>MediaDevices</pnpx:X_devicecategory> <pnpx:X_harDWareID>VEN_0106&DEV_0006&REV_01</pnpx:X_harDWareID> <df:X_devicecategory>display.TV Multimedia.DMR</df:X_devicecategory> <av:X_TrackID_DeviceInfo xmlns:av="urn:schemas-sony-com:av"> <av:X_TrackID_BaseURL>http://192.168.1.11/sony/BgmSearch</av:X_TrackID_BaseURL> </av:X_TrackID_DeviceInfo> <av:X_DIALEX_DeviceInfo xmlns:av="urn:schemas-sony-com:av"> <av:X_DIALEX_AppsListURL>http://192.168.1.11/DIAL/sony/appList</av:X_DIALEX_AppsListURL> </av:X_DIALEX_DeviceInfo> <av:X_ScalarWebAPI_DeviceInfo xmlns:av="urn:schemas-sony-com:av"> <av:X_ScalarWebAPI_Version>1.0</av:X_ScalarWebAPI_Version> <av:X_ScalarWebAPI_BaseURL>http://192.168.1.11/sony</av:X_ScalarWebAPI_BaseURL> <av:X_ScalarWebAPI_ServiceList> <av:X_ScalarWebAPI_ServiceType>guIDe</av:X_ScalarWebAPI_ServiceType> <av:X_ScalarWebAPI_ServiceType>system</av:X_ScalarWebAPI_ServiceType> <av:X_ScalarWebAPI_ServiceType>vIDeoScreen</av:X_ScalarWebAPI_ServiceType> <av:X_ScalarWebAPI_ServiceType>audio</av:X_ScalarWebAPI_ServiceType> <av:X_ScalarWebAPI_ServiceType>avContent</av:X_ScalarWebAPI_ServiceType> <av:X_ScalarWebAPI_ServiceType>recording</av:X_ScalarWebAPI_ServiceType> <av:X_ScalarWebAPI_ServiceType>appControl</av:X_ScalarWebAPI_ServiceType> <av:X_ScalarWebAPI_ServiceType>browser</av:X_ScalarWebAPI_ServiceType> <av:X_ScalarWebAPI_ServiceType>notification</av:X_ScalarWebAPI_ServiceType> <av:X_ScalarWebAPI_ServiceType>cec</av:X_ScalarWebAPI_ServiceType> <av:X_ScalarWebAPI_ServiceType>accessControl</av:X_ScalarWebAPI_ServiceType> <av:X_ScalarWebAPI_ServiceType>irCommandProxy</av:X_ScalarWebAPI_ServiceType> </av:X_ScalarWebAPI_ServiceList> </av:X_ScalarWebAPI_DeviceInfo> <av:X_Rdis_DeviceInfo xmlns:av="urn:schemas-sony-com:av"> <av:X_Rdis_Version>1.0</av:X_Rdis_Version> <av:X_Rdis_SESSION_CONTRol>false</av:X_Rdis_SESSION_CONTRol> <av:X_Rdis_ENTRY_PORT>20677</av:X_Rdis_ENTRY_PORT> </av:X_Rdis_DeviceInfo> </device></root>
使用此信息,如果我有链接,如何请求电视播放视频?我试图根据我在网上阅读的内容并获得此代码到目前为止,这应该设置AVTransportURI,但它一直给出错误500内部服务器错误.
private const string SetAvTransportURIXml = "<?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:SetAVTransportURI xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">" + "<InstanceID>0</InstanceID>" + "<CurrentURI>{0}</CurrentURI>" + "<CurrentURIMetaData></CurrentURIMetaData>" + "</u:SetAVTransportURI>" + "</s:Body>" + "</s:Envelope>"; public voID PlayVIDeo(string vIDeolink) { byte[] bytes; bytes = EnCoding.UTF8.GetBytes(String.Format(SetAvTransportURIXml,vIDeolink)); httpWebRequest request = (httpWebRequest)WebRequest.Create("http://192.168.1.11:52323/upnp/control/AVTransport"); request.headers.Add("SOAPAction","\"urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI\""); request.ContentType = "text/xml; enCoding=\"utf-8\""; request.ContentLength = bytes.Length; request.Method = "POST"; Stream requestStream = request.GetRequestStream(); requestStream.Write(bytes,bytes.Length); requestStream.Flush(); requestStream.Close(); var response = (httpWebResponse) request.GetResponse(); if (response.StatusCode == httpStatusCode.OK) { Stream responseStream = response.GetResponseStream(); if (responseStream == null) return; string responseStr = new StreamReader(responseStream).ReadToEnd(); Console.Writeline(responseStr); } }
任何帮助将不胜感激,谢谢.
解决方法 尝试在CurrentURIMetaData参数中放入一些DIDL-lite元数据.如果我把那个场地留空,我的LG电视拒绝播放任何东西.例如,以下对我有用(当然,当嵌入在外部XML结构中时需要进行转义):
<?xml version="1.0"?><DIDL-lite xmlns="urn:schemas-upnp-org:Metadata-1-0/DIDL-lite/" xmlns:upnp="urn:schemas-upnp-org:Metadata-1-0/upnp/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sec="http://www.sec.co.kr/"><item ID="f-0" parentID="0" restricted="0"> <dc:Title>VIDeo</dc:Title> <dc:creator>Anonymous</dc:creator> <upnp:class>object.item.vIDeoItem</upnp:class> <res protocolinfo="http-get:*:vIDeo/mp4:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000">{0}</res></item></DIDL-lite>
此外,可能需要在对电视媒体请求的http响应中(在您提供的URL处)具有一些特殊标头.我的LG电视拒绝播放,除非媒体文件响应具有以下标题(区分大小写的BTW!):
contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000transferMode.dlna.org: Streaming
实施UPnP / DLNA时可能会出现很多问题.如果电视不喜欢任何东西,它就会拒绝接受它.错误消息可能非常不明确.需要大量的测试迭代来确定如何强制不同的DLNA设备实现以进行协作.市场上的许多/大多数电视设备仅实现了规格的一小部分.以他们自己的方式.
在Github代码搜索中搜索SetAVTransportURI等有助于弄清楚其他人是如何实现的.
总结以上是内存溢出为你收集整理的如何使用UPnP C#发送SetAVTransportURI?全部内容,希望文章能够帮你解决如何使用UPnP C#发送SetAVTransportURI?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)