DLNA(二)

接:DLNA(一)
下面我們來看看具體的控制(這里還是以悅me為例

具體的代碼見gitHubDemo里面的具體的包括實(shí)現(xiàn)都有具體的實(shí)現(xiàn)

服務(wù)動作請求

1.設(shè)置圖片的播放

http://192.168.124.43:1266/AVTransport/skyworth&208B3756FFED&192.168.124.43/control.xml

<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
    <s:Body>
        <u:SetAVTransportURI>
            <InstanceID>0</InstanceID>
            <CurrentURI>http://pic2.nipic.com/20090506/2256386_141149004_2.jpg</CurrentURI>
            <CurrentURIMetaData>&lt;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:dlna="urn:schemas-dlna-org:metadata-1-0/" xmlns:sec="http://www.sec.co.kr/"&gt;&lt;item id="filePath" parentID="0" restricted="1"&gt;&lt;upnp:class&gt;object.item.imageItem&lt;/upnp:class&gt;&lt;dc:title&gt;
            IMAG1466&lt;/dc:title&gt;&lt;dc:creator&gt;Unknown Artist&lt;/dc:creator&gt;&lt;upnp:artist&gt;Unknown Artist&lt;/upnp:artist&gt;&lt;upnp:albumArtURI&gt;http://IP:PORT/filePath&lt;/upnp:albumArtURI&gt;&lt;upnp:album&gt;Unknown Album&lt;/upnp:album&gt;&lt;res protocolInfo="http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_LRG;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000"&gt;http://IP:PORT/filePath&lt;/res&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData>
        </u:SetAVTransportURI>
    </s:Body>
</s:Envelope>

//返回response
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <u:SetAVTransportURIResponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1" />
    </s:Body>
</s:Envelope>

2.圖片開始播放

http://192.168.124.43:1266/AVTransport/skyworth&208B3756FFED&192.168.124.43/control.xml

<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
    <s:Body>
        <u:Play>
            <InstanceID>0</InstanceID>
            <Speed>1</Speed>
        </u:Play>
    </s:Body>
</s:Envelope>

//response
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <u:PlayResponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1" />
    </s:Body>
</s:Envelope>

3.獲取當(dāng)前圖片播放信息

http://192.168.124.43:1266/AVTransport/skyworth&208B3756FFED&192.168.124.43/control.xml

<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
    <s:Body>
        <u:GetTransportInfo>
            <InstanceID>0</InstanceID>
        </u:GetTransportInfo>
    </s:Body>
</s:Envelope>

//response
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <u:GetTransportInfoResponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
            <CurrentTransportState>NO_MEDIA_PRESENT</CurrentTransportState>
            <CurrentTransportStatus>OK</CurrentTransportStatus>
            <CurrentSpeed>1</CurrentSpeed>
        </u:GetTransportInfoResponse>
    </s:Body>
</s:Envelope>

4.停止圖片播放

http://192.168.124.43:1266/AVTransport/skyworth&208B3756FFED&192.168.124.43/control.xml

<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
    <s:Body>
        <u:Stop>
            <InstanceID>0</InstanceID>
        </u:Stop>
    </s:Body>
</s:Envelope>

//response
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <u:StopResponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1" />
    </s:Body>
</s:Envelope>

5.設(shè)置視頻播放

http://192.168.124.43:1266/AVTransport/skyworth&208B3756FFED&192.168.124.43/control.xml

<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
    <s:Body>
        <u:SetAVTransportURI>
            <InstanceID>0</InstanceID>
            <CurrentURI>http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4</CurrentURI>
            <CurrentURIMetaData>&lt;DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sec="http://www.sec.co.kr/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"&gt;&lt;item id="f-0" parentID="0" restricted="0"&gt;&lt;dc:title&gt;Video&lt;/dc:title&gt;&lt;dc:creator&gt;Anonymous&lt;/dc:creator&gt;&lt;upnp:class&gt;object.item.videoItem&lt;/upnp:class&gt;&lt;res protocolInfo="http-get:*:video/*:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000" sec:URIType="public"&gt;%@&lt;/res&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData>
        </u:SetAVTransportURI>
    </s:Body>
</s:Envelope>

//response
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <u:SetAVTransportURIResponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1" />
    </s:Body>
</s:Envelope>

6.獲取當(dāng)前視頻播放信息

http://192.168.124.43:1266/AVTransport/skyworth&208B3756FFED&192.168.124.43/control.xml

<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
    <s:Body>
        <u:GetTransportInfo>
            <InstanceID>0</InstanceID>
        </u:GetTransportInfo>
    </s:Body>
</s:Envelope>

//response
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <u:GetTransportInfoResponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
            <CurrentTransportState>NO_MEDIA_PRESENT</CurrentTransportState>
            <CurrentTransportStatus>OK</CurrentTransportStatus>
            <CurrentSpeed>1</CurrentSpeed>
        </u:GetTransportInfoResponse>
    </s:Body>
</s:Envelope>

7.視頻播放指令

http://192.168.124.43:1266/AVTransport/skyworth&208B3756FFED&192.168.124.43/control.xml

<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
    <s:Body>
        <u:Play>
            <InstanceID>0</InstanceID>
            <Speed>1</Speed>
        </u:Play>
    </s:Body>
</s:Envelope>


//response
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <u:PlayResponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1" />
    </s:Body>
</s:Envelope>

8.獲取音量

http://192.168.124.43:1266/RenderingControl/skyworth&208B3756FFED&192.168.124.43/control.xml

<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">
    <s:Body>
        <u:GetVolume>
            <InstanceID>0</InstanceID>
            <Channel>Master</Channel>
        </u:GetVolume>
    </s:Body>
</s:Envelope>

//response
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <u:GetVolumeResponse xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">
            <CurrentVolume>100</CurrentVolume>
        </u:GetVolumeResponse>
    </s:Body>
</s:Envelope>

9.設(shè)置音量

http://192.168.124.43:1266/RenderingControl/skyworth&208B3756FFED&192.168.124.43/control.xml

<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">
    <s:Body>
        <u:SetVolume>
            <InstanceID>0</InstanceID>
            <Channel>Master</Channel>
            <DesiredVolume>5</DesiredVolume>
        </u:SetVolume>
    </s:Body>
</s:Envelope>

//response
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <u:SetVolumeResponse xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1" />
    </s:Body>
</s:Envelope>

10.暫停視頻指令

http://192.168.124.43:1266/AVTransport/skyworth&208B3756FFED&192.168.124.43/control.xml

<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
    <s:Body>
        <u:Pause>
            <InstanceID>0</InstanceID>
        </u:Pause>
    </s:Body>
</s:Envelope>

//response
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <u:PauseResponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1" />
    </s:Body>
</s:Envelope>

11.播放快進(jìn)退

http://192.168.124.43:1266/AVTransport/skyworth&208B3756FFED&192.168.124.43/control.xml

<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
    <s:Body>
        <u:Seek>
            <InstanceID>0</InstanceID>
            <Unit>REL_TIME</Unit>
            <Target>00:01:44</Target>
        </u:Seek>
    </s:Body>
</s:Envelope>

//response
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <u:SeekResponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1" />
    </s:Body>
</s:Envelope>

上述對于基本的控制指令都有了,發(fā)現(xiàn)要實(shí)現(xiàn)網(wǎng)絡(luò)的都應(yīng)該沒問題了,但是老大需要我去實(shí)現(xiàn)本地的圖片/視頻的播放,結(jié)果還是得用其他的方式將本地的資源變成http的方式來訪問。
詳見 DLNA(三)

友情鏈接:

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容