Link Search Menu Expand Document

ContentDirectoryService

Browse for local content

The ContentDirectoryService is available on these models: v1-S1 / v1-S5 / v1-S9.

  1. Available actions
    1. Browse
    2. CreateObject
    3. DestroyObject
    4. FindPrefix
    5. GetAlbumArtistDisplayOption
    6. GetAllPrefixLocations
    7. GetBrowseable
    8. GetLastIndexChange
    9. GetSearchCapabilities
    10. GetShareIndexInProgress
    11. GetSortCapabilities
    12. GetSystemUpdateID
    13. RefreshShareIndex
    14. RequestResort
    15. SetBrowseable
    16. UpdateObject
  2. Events
    1. Subscribe to events
    2. Event variables
  3. Custom errors

Service data

name value
Control URL http://192.168.x.x:1400/MediaServer/ContentDirectory/Control
Event subscription URL http://192.168.x.x:1400/MediaServer/ContentDirectory/Event
Discovery url http://192.168.x.x:1400/xml/ContentDirectory1.xml
Service ID urn:upnp-org:serviceId:ContentDirectory
Service type urn:schemas-upnp-org:service:ContentDirectory:1

Sample request

POST /MediaServer/ContentDirectory/Control
Host: 192.168.x.x:1400
soapaction: "urn:schemas-upnp-org:service:ContentDirectory:1#{ActionName}"
Content-Type: text/xml; charset="utf-8"

<?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>
    {ActionBodyHere}
  </s:Body>
</s:Envelope>

Available actions

Browse

Browse for content.

Action body:

<u:Browse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
  <ObjectID>string</ObjectID>
  <BrowseFlag>string</BrowseFlag>
  <Filter>string</Filter>
  <StartingIndex>ui4</StartingIndex>
  <RequestedCount>ui4</RequestedCount>
  <SortCriteria>string</SortCriteria>
</u:Browse>

Inputs:

parameter type description
ObjectID string The search query, [‘A:ARTIST’,’A:ALBUMARTIST’,’A:ALBUM’,’A:GENRE’,’A:COMPOSER’,’A:TRACKS’,’A:PLAYLISTS’] with optionally ‘:search+query’ behind it.
BrowseFlag string How to browse Allowed values: BrowseMetadata / BrowseDirectChildren
Filter string Which fields should be returned ‘*’ for all.
StartingIndex ui4 Paging, where to start
RequestedCount ui4 Paging, number of items
SortCriteria string Sort the results based on metadata fields. ‘+upnp:artist,+dc:title’ for sorting on artist then on title.

Outputs:

parameter type description
Result string  
NumberReturned ui4  
TotalMatches ui4  
UpdateID ui4  

Remarks Some libraries support a BrowseAndParse, so you don't have to parse the xml.

CreateObject

Action body:

<u:CreateObject xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
  <ContainerID>string</ContainerID>
  <Elements>string</Elements>
</u:CreateObject>

Inputs:

parameter type description
ContainerID string  
Elements string  

Outputs:

parameter type description
ObjectID string  
Result string  

DestroyObject

Action body:

<u:DestroyObject xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
  <ObjectID>string</ObjectID>
</u:DestroyObject>

Inputs:

parameter type description
ObjectID string  

FindPrefix

Action body:

<u:FindPrefix xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
  <ObjectID>string</ObjectID>
  <Prefix>string</Prefix>
</u:FindPrefix>

Inputs:

parameter type description
ObjectID string  
Prefix string  

Outputs:

parameter type description
StartingIndex ui4  
UpdateID ui4  

GetAlbumArtistDisplayOption

Action body:

<u:GetAlbumArtistDisplayOption xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
</u:GetAlbumArtistDisplayOption>

No input arguments

Outputs:

parameter type description
AlbumArtistDisplayOption string  

GetAllPrefixLocations

Action body:

<u:GetAllPrefixLocations xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
  <ObjectID>string</ObjectID>
</u:GetAllPrefixLocations>

Inputs:

parameter type description
ObjectID string  

Outputs:

parameter type description
TotalPrefixes ui4  
PrefixAndIndexCSV string  
UpdateID ui4  

GetBrowseable

Action body:

<u:GetBrowseable xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
</u:GetBrowseable>

No input arguments

Outputs:

parameter type description
IsBrowseable boolean  

GetLastIndexChange

Action body:

<u:GetLastIndexChange xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
</u:GetLastIndexChange>

No input arguments

Outputs:

parameter type description
LastIndexChange string  

GetSearchCapabilities

Action body:

<u:GetSearchCapabilities xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
</u:GetSearchCapabilities>

No input arguments

Outputs:

parameter type description
SearchCaps string  

GetShareIndexInProgress

Action body:

<u:GetShareIndexInProgress xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
</u:GetShareIndexInProgress>

No input arguments

Outputs:

parameter type description
IsIndexing boolean  

GetSortCapabilities

Action body:

<u:GetSortCapabilities xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
</u:GetSortCapabilities>

No input arguments

Outputs:

parameter type description
SortCaps string  

GetSystemUpdateID

Action body:

<u:GetSystemUpdateID xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
</u:GetSystemUpdateID>

No input arguments

Outputs:

parameter type description
Id ui4  

RefreshShareIndex

Action body:

<u:RefreshShareIndex xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
  <AlbumArtistDisplayOption>string</AlbumArtistDisplayOption>
</u:RefreshShareIndex>

Inputs:

parameter type description
AlbumArtistDisplayOption string  

RequestResort

Action body:

<u:RequestResort xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
  <SortOrder>string</SortOrder>
</u:RequestResort>

Inputs:

parameter type description
SortOrder string  

SetBrowseable

Action body:

<u:SetBrowseable xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
  <Browseable>boolean</Browseable>
</u:SetBrowseable>

Inputs:

parameter type description
Browseable boolean  

UpdateObject

Action body:

<u:UpdateObject xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
  <ObjectID>string</ObjectID>
  <CurrentTagValue>string</CurrentTagValue>
  <NewTagValue>string</NewTagValue>
</u:UpdateObject>

Inputs:

parameter type description
ObjectID string  
CurrentTagValue string  
NewTagValue string  

Events

The ContentDirectoryService has variables that might be emitted if you subscribe to events.

Subscribe to events

SUBSCRIBE /MediaServer/ContentDirectory/Event
Host: 192.168.x.x:1400
callback: <http://...>
NT: upnp:event
Timeout: Second-3600

Event variables

Variable Sends events* type possible values
Browseable boolean  
ContainerUpdateIDs string  
FavoritePresetsUpdateID string  
FavoritesUpdateID string  
RadioFavoritesUpdateID ui4  
RadioLocationUpdateID ui4  
RecentlyPlayedUpdateID string  
SavedQueuesUpdateID string  
SearchCapabilities string  
ShareIndexInProgress boolean  
ShareIndexLastError string  
ShareListUpdateID string  
SortCapabilities string  
SystemUpdateID ui4  
UserRadioUpdateID string  

If the variable has a in the Sends events column, the service discovery specifies this variable emits events. A doesn’t mean that is won’t emit events.

Custom errors

The ContentDirectoryService has the following known custom errors.

Error code Description
701 No such object
702 Invalid CurrentTagValue
703 Invalid NewTagValue
704 Required tag
705 Read-only tag
706 Parameter mismatch
708 Invalid search criteria
709 Invalid sort criteria
710 No such container
711 Restricted object
712 Bad metadata
713 Restricted parent object
714 No such source resource
715 Resource access denied
716 Transfer busy
717 No such file transfer
718 No such destination resource
719 Destinaton resource access denied
720 Cannot process the request

This file is automatically generated with @svrooij/sonos-docs, do not edit manually.