SONOS getMediaURI endpoint not called by player

99 Views Asked by At

I’m developing a custom music service for SONOS in which custom playlists are provided to be played (Spotify alike).

I’ve implemented the required endpoints and I can see while debugging that the GETLASTUPDATE and GETMETADATA endpoints are called and that the information is show in the APP (Playlists list, track list by playlist and artist and album info).

The issue is, When I try to reproduce a complete playlist or a track I get an

Unable to add songs to Queue

message and no call is done by the app to the API.

What am I missing here?

Below you may find the called the endpoints output.

Request:

<getMetadata xmlns="http://www.sonos.com/Services/1.1">
    <id>root</id>
    <index>0</index>
    <count>100</count>
</getMetadata>

Response:

<ns1:getMetadataResponse>
    <ns1:getMetadataResult>
        <ns1:index>0</ns1:index>
        <ns1:count>9</ns1:count>
        <ns1:total>9</ns1:total>
        <ns1:mediaCollection>
            <ns1:id>PLAYLIST:10:2</ns1:id>
            <ns1:itemType>playlist</ns1:itemType>
            <ns1:title>Anos 90</ns1:title>
            <ns1:summary>Relembre os hits que marcaram os anos 90. Da música pop ao grunge, esta playlist conta com as presenças de Alanis Morissette, Oasis, Pearl Jam e The Cranberries</ns1:summary>
            <ns1:canPlay>true</ns1:canPlay>             
<ns1:albumArtURI>https://xxx/xxdata/images/playlists/default.jpg</ns1:albumArtURI>
        </ns1:mediaCollection>            
    </ns1:getMetadataResult>
</ns1:getMetadataResponse>

Request:

<getMetadata xmlns="http://www.sonos.com/Services/1.1">
    <id>PLAYLIST:10:2</id>
    <index>0</index>
    <count>100</count>
</getMetadata>

Response:

<ns1:getMetadataResponse>
    <ns1:getMetadataResult>
        <ns1:index>0</ns1:index>
        <ns1:count>100</ns1:count>
        <ns1:total>338</ns1:total>
        <ns1:mediaMetadata>
            <ns1:id>track:300</ns1:id>
            <ns1:title>Black Hole Sun</ns1:title>
            <ns1:mimeType>audio/mp3</ns1:mimeType>
            <ns1:itemType>track</ns1:itemType>
            <ns1:trackMetadata>
                <ns1:albumId>album:1390</ns1:albumId>
                <ns1:duration>253970</ns1:duration>
                <ns1:artistId>artist:543</ns1:artistId>
                <ns1:artist>Soundgarden</ns1:artist>
                <ns1:album>Superunknown</ns1:album>
                <ns1:albumArtURI>https://xxxx/musiccover.aspx?pk=xxx-xxx-xxxx-xxxx</ns1:albumArtURI>
                </ns1:trackMetadata>
            </ns1:mediaMetadata>
        <ns1:mediaMetadata>
            <ns1:id>track:514</ns1:id>
            <ns1:title>Don't Speak</ns1:title>
            <ns1:mimeType>audio/mp3</ns1:mimeType>
            <ns1:itemType>track</ns1:itemType>
            <ns1:trackMetadata>
               <ns1:albumId>album:1128</ns1:albumId>
               <ns1:duration>207196</ns1:duration>
               <ns1:artistId>artist:467</ns1:artistId>
               <ns1:artist>No Doubt</ns1:artist>
               <ns1:album>Tragic Kingdom</ns1:album>
               <ns1:albumArtURI>https://xxxx/musiccover.aspx?pk=xxx-xxx-xxxx-xxxx</ns1:albumArtURI>
          </ns1:trackMetadata>
      </ns1:mediaMetadata>
    </ns1:getMetadataResult>
</ns1:getMetadataResponse>
1

There are 1 best solutions below

1
RJM On

Is that last snippet your actual response? It could be a number of things, but I think the issue may be that your response claims to return 100 results when it only contains 2. To test this, try to use

        <ns1:index>0</ns1:index>
        <ns1:count>2</ns1:count>
        <ns1:total>2</ns1:total>
        <ns1:mediaMetadata>. . . <ns1:mediaMetadata>
        <ns1:mediaMetadata>. . . <ns1:mediaMetadata>

instead of count=100, total=338. The player may be trying to enqueue the rest of the tracks and failing to do so, causing the error.

If you use the ... menu on the track from the Sonos app's browse, and select "Play Song" the player should enqueue only the one track and attempt to play it without dealing with the pagination of the playlist container.