Search code examples
soapsonos

Removing track from playlist call deleteContainer instead removeFromContainer


When I am trying to remove tracks from users playlist, controller send SOAP request with method deleteContainer, i.e.:

<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <credentials xmlns="http://www.sonos.com/Services/1.1">
      <sessionId>574ae2c7e83b03.16748534_6f1bc18ac2878c101d2f28a0a4cdf2a8</sessionId>
      <deviceId>B8-E9-37-EF-29-1E:8</deviceId>
      <deviceProvider>Sonos</deviceProvider>
    </credentials>
  </s:Header>
  <s:Body>
    <deleteContainer xmlns="http://www.sonos.com/Services/1.1">
      <id>TRACK:272228:13306</id>
    </deleteContainer>
  </s:Body>
</s:Envelope>

But I can see there is a method removeFromContainer and I assume this method should be used for removing tracks from a playlist.

I have this problem in Android APP and in MacOS Sonos App. And I am removing tracks, not playlists. When removing playlists, it calls the same method deleteContainer but with the right ID, i.e.: PLAYLISTS:PLAYLIST:23952

Am I wrong? In which case method removeFromContainer will be used?

Playlists root section

Request

<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <credentials xmlns="http://www.sonos.com/Services/1.1">
      <sessionId>574dd9f69e8ad1.86333620_6f1bc18ac2878c101d2f28a0a4cdf2a8</sessionId>
      <deviceId>B8-E9-37-EF-29-1E:8</deviceId>
      <deviceProvider>Sonos</deviceProvider>
    </credentials>
  </s:Header>
  <s:Body>
    <getMetadata xmlns="http://www.sonos.com/Services/1.1">
      <id>playlists</id>
      <index>0</index>
      <count>100</count>
    </getMetadata>
  </s:Body>
</s:Envelope>

Response

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:ns1="http://www.sonos.com/Services/1.1">
    <SOAP-ENV:Body>
        <ns1:getMetadataResponse>
            <ns1:getMetadataResult>
                <ns1:index>0</ns1:index>
                <ns1:count>2</ns1:count>
                <ns1:total>2</ns1:total>
                <ns1:mediaCollection readOnly="false" userContent="true" renameable="true">
                    <ns1:id>PLAYLISTS:PLAYLIST:23952</ns1:id>
                    <ns1:itemType>favorite</ns1:itemType>
                    <ns1:displayType>list</ns1:displayType>
                    <ns1:title>Another playlist</ns1:title>
                    <ns1:summary>39 songs 18486</ns1:summary>
                    <ns1:canPlay>true</ns1:canPlay>
                    <ns1:canEnumerate>true</ns1:canEnumerate>
                </ns1:mediaCollection>
                <ns1:mediaCollection readOnly="false" userContent="true" renameable="true">
                    <ns1:id>PLAYLISTS:PLAYLIST:28331</ns1:id>
                    <ns1:itemType>favorite</ns1:itemType>
                    <ns1:displayType>list</ns1:displayType>
                    <ns1:title>Some playlist</ns1:title>
                    <ns1:summary>21 songs 10454</ns1:summary>
                    <ns1:canPlay>true</ns1:canPlay>
                    <ns1:canEnumerate>true</ns1:canEnumerate>
                </ns1:mediaCollection>
            </ns1:getMetadataResult>
        </ns1:getMetadataResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Get playlist items

Request

<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <credentials xmlns="http://www.sonos.com/Services/1.1">
      <sessionId>574dd9f69e8ad1.86333620_6f1bc18ac2878c101d2f28a0a4cdf2a8</sessionId>
      <deviceId>B8-E9-37-EF-29-1E:8</deviceId>
      <deviceProvider>Sonos</deviceProvider>
    </credentials>
  </s:Header>
  <s:Body>
    <getMetadata xmlns="http://www.sonos.com/Services/1.1">
      <id>PLAYLISTS:PLAYLIST:28331</id>
      <index>0</index>
      <count>100</count>
    </getMetadata>
  </s:Body>
</s:Envelope>

Response

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:ns1="http://www.sonos.com/Services/1.1">
    <SOAP-ENV:Body>
        <ns1:getMetadataResponse>
            <ns1:getMetadataResult>
                <ns1:index>0</ns1:index>
                <ns1:count>21</ns1:count>
                <ns1:total>21</ns1:total>
                <ns1:mediaMetadata>
                    <ns1:id>TRACK:273257:14098</ns1:id>
                    <ns1:itemType>track</ns1:itemType>
                    <ns1:displayType></ns1:displayType>
                    <ns1:title>Dark Star</ns1:title>
                    <ns1:summary>Phil Lesh &amp; Friends</ns1:summary>
                    <ns1:mimeType>audio/mp3</ns1:mimeType>
                    <ns1:trackMetadata>
                        <ns1:artist>Phil Lesh &amp; Friends</ns1:artist>
                        <ns1:duration>1030</ns1:duration>
                        <ns1:rating>0</ns1:rating>
                        <ns1:albumArtURI>http://www.livedownloads.com/images/shows/phil160318_02.jpg</ns1:albumArtURI>
                        <ns1:canPlay>true</ns1:canPlay>
                        <ns1:canSkip>true</ns1:canSkip>
                    </ns1:trackMetadata>
                </ns1:mediaMetadata>
                [other items]
            </ns1:getMetadataResult>
        </ns1:getMetadataResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

On item remove from playlist

Request

<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <credentials xmlns="http://www.sonos.com/Services/1.1">
      <sessionId>574dd9f69e8ad1.86333620_6f1bc18ac2878c101d2f28a0a4cdf2a8</sessionId>
      <deviceId>B8-E9-37-EF-29-1E:8</deviceId>
      <deviceProvider>Sonos</deviceProvider>
    </credentials>
  </s:Header>
  <s:Body>
    <deleteContainer xmlns="http://www.sonos.com/Services/1.1">
      <id>TRACK:263512:12867</id>
    </deleteContainer>
  </s:Body>
</s:Envelope>

Environment

From MacOS Sonos app About dialog:

Version: 6.2.2
Build: 31927221
Sonos ID: 115034936

Sonos device info:

PLAY:1: Living Room
Serial Number: B8-E9-37-EF-29-1E:8
Version: 6.2 (build 31926010)
Hardware Version: 1.8.3.7-1
IP Address: 192.168.0.108
WM: 1
OTP: 

From Android Sonos app

Sonos ID: 115034936
Version: 6.2.2 (build 31927151)

http://192.168.0.108:1400/status/VERSION

contents of /VERSION
31.9-26010

Display type pmap

<DisplayType id="list">
    <DisplayMode>LIST</DisplayMode>
    <ItemThumbnails source="albumArtUri"/>
    <Lines>
        <Line token="title"/>
        <Line token="summary"/>
    </Lines>
</DisplayType>

Solution

  • The way playlist editing was designed, the controller expects the individual playlist containers to be of itemType "playlist". The way to fix the behavior you are seeing above, is to set each of the individual playlist containers to itemType "playlist".

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope 
        xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
        xmlns:ns1="http://www.sonos.com/Services/1.1">
      <SOAP-ENV:Body>
        <ns1:getMetadataResponse>
            <ns1:getMetadataResult>
                <ns1:index>0</ns1:index>
                <ns1:count>2</ns1:count>
                <ns1:total>2</ns1:total>
                <ns1:mediaCollection readOnly="false" userContent="true" renameable="true">
                    <ns1:id>PLAYLISTS:PLAYLIST:23952</ns1:id>
                    <ns1:itemType>playlist</ns1:itemType>
                    <ns1:displayType>list</ns1:displayType>
                    <ns1:title>Another playlist</ns1:title>
                    <ns1:summary>39 songs 18486</ns1:summary>
                    <ns1:canPlay>true</ns1:canPlay>
                    <ns1:canEnumerate>true</ns1:canEnumerate>
                </ns1:mediaCollection>
                <ns1:mediaCollection readOnly="false" userContent="true" renameable="true">
                    <ns1:id>PLAYLISTS:PLAYLIST:28331</ns1:id>
                    <ns1:itemType>playlist</ns1:itemType>
                    <ns1:displayType>list</ns1:displayType>
                    <ns1:title>Some playlist</ns1:title>
                    <ns1:summary>21 songs 10454</ns1:summary>
                    <ns1:canPlay>true</ns1:canPlay>
                    <ns1:canEnumerate>true</ns1:canEnumerate>
                </ns1:mediaCollection>
            </ns1:getMetadataResult>
        </ns1:getMetadataResponse>
    </SOAP-ENV:Body>
    

    Since the parent container has an itemType of "favorites", the children will also inherit the favorites behavior and you will still be able to have the content of the individual playlists refreshed upon the getLastUpdate call. You could also include the containsFavorite node within mediaCollection and set the value to true for the individual playlists (see documentation here on containsFavorite: http://musicpartners.sonos.com/node/83).

    We will investigate internally the behavior when an itemType other than "playlist" is used for individual playlist containers. Let us know if you have any further questions.