Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

having problems with setting MetaData on AVTransport SetAVTransportURI #5

Open
moda20 opened this issue May 18, 2020 · 5 comments
Open

Comments

@moda20
Copy link

moda20 commented May 18, 2020

Hey !
I am having a hard time getting the Action SetAVTransportURI to work properly with MetaData. The URI gets passed correctly but the MEtaData somehow is not being passed at all, it is like it is getting deleted somehow.

I tried many other UPnP Controls and they worked fine. I couldn't figure out if my MetaData is not written correctly or not, but after trying what is supposed to be a sure-to-work example it still didn't pass the MetaData. So I resolved to be an issue with this package.

Here is the code I am using, as you can see it is standard :

service.invokeAction("SetAVTransportURI", {
      "InstanceID":"0",
      "CurrentURI":uri??"",
      "CurrentURIMetaData":'<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/">'
          '<item id="0" parentID="-1" restricted="false">'
          '<upnp:class>object.item.audioItem.musicTrack</upnp:class>'
          '<dc:title>Some Movie Title</dc:title>'
          '<dc:creator>John Doe</dc:creator>'
          '<dc:genre>Rock</dc:genre>'
          '<dc:abstract>Rock Abstract</dc:abstract>'
          '<upnp:region>REGION US</upnp:region>'
          '<res protocolInfo="http-get:*:audio/mpeg:*">http://192.168.1.229:8090/AT1983/LOST%20LOVE%20IN%20THE%20RAIN.mp3</res>'
          '</item>'
          '</DIDL-Lite>'
    });

I did inspect the final XML body of the request and it did include the correct XML with the data I added in the XML above.

I am using Kodi 18 to be my renderer, it maybe a fault in there but I doubt it. Please tell me what you think and if a solution is possible.

@moda20
Copy link
Author

moda20 commented May 23, 2020

first, it turned out that this package has a bug that replaces for some reason any "&" character with ";amp" character which is not really how things should work for UPnP.

The second thing is that the CurrentURIMetaData is supposed to be an escaped XML, which no docs tell that. So first you need to convert it to XML using the XML parser and then escaped it using the dart convert html escape method like below :

import 'package:xml/xml.dart' as xml;
import 'dart:convert' show HtmlEscape;

(htmlEscape.convert(xml.parse('<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/">'
          '<item id="0" parentID="-1" restricted="false">'
          '<upnp:class>object.item.audioItem.musicTrack</upnp:class>'
          '<dc:title>Some Movie Title</dc:title>'
          '<dc:creator>John Doe</dc:creator>'
          '<dc:genre>Rock</dc:genre>'
          '<dc:abstract>Rock Abstract</dc:abstract>'
          '<upnp:region>REGION US</upnp:region>'
          '<res protocolInfo="http-get:*:audio/mpeg:*">http://192.168.1.229:8090/AT1983/LOST%20LOVE%20IN%20THE%20RAIN.mp3</res>'
          '</item>'
          '</DIDL-Lite>').toString()))

I will be fine this in a pull requests.

@dxvid-pts
Copy link

Do you have a full example on how to set the AVTransportURI? It doesn't work even with your code above.

@moda20
Copy link
Author

moda20 commented Jan 26, 2021

@peterscodee the url should be set elsewhere, not in the <DIDL>. here is the full code I am using :

return await service.invokeAction("SetAVTransportURI", {
      "InstanceID":"0",
      "CurrentURI":uri??"",
      "CurrentURIMetaData":(htmlEscape.convert(xml.parse('<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/">'
          '<item id="0" parentID="-1" restricted="false">'
          '<upnp:class>${Objectclass??"object.item.audioItem.musicTrack"}</upnp:class>'
          '<dc:title>${title??"Unknown Title"}</dc:title>'
          '<dc:creator>${creator??"Unknown creator"}</dc:creator>'
          '<upnp:artist>${creator??"Unknown Artist"}</upnp:artist>'
          '<upnp:album>${Album}</upnp:album>'
          '<upnp:originalTrackNumber>${trackNumber??1}</upnp:originalTrackNumber>'
          '<dc:genre>${genre}</dc:genre>'
          '<upnp:albumArtURI dlna:profileID="JPEG_TN" xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/">${artUri}</upnp:albumArtURI>'
          '<res duration="${Duration}" size="${Size}" protocolInfo="http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000">${uri}</res>'
          '</item>'
          '</DIDL-Lite>').toString()))
    });

the uri should be put in the CurrentURI attribute.

@dxvid-pts
Copy link

Thank you so much, you have saved me many hours!

@LorenzoVianello
Copy link

Hi, i discovered that your solutions works form me too.
My new problem is another.
I'm sendig upnp track to Linkplay module, but it sends data using html.convert characters, which are not read correctly from GetInfoEx action.
Have you any info about how can i retrieve all this without any problem (except unencoding with html chars, beacusa data are read from linkplay app, and i cannot touch that in any way).
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants