Add actions
To get more information about the current item type (track, album, and so on), the listener selects the ellipsis (...) to display the Info View. The Info View is a screen with actions listeners can select for the current item type. The Info View is available for most item types but we'll show only a few examples.
The following screens display the Info View for an album and a song while browsing an album.
The following screen displays the Info View for a playing song:
For a streaming station:
The actions listeners can select are grouped as default actions and custom actions. You can provide custom actions but you cannot modify the default actions.
Default actions
Default actions are built-in to the Sonos app and display automatically. The Sonos default actions that display depend on the content's itemType
and viewing mode, either browse or now-playing. Default actions display at the beginning of the Info View.
Some of the default actions are listed below. Sonos may add other actions in the future.
- Add Song to My Sonos
- Add to Sonos Playlist
- Play in Another Room...
- Play Next
- Add to End of Queue
- More
- Add Song to My Sonos
- Add Song to Sonos Playlist
Custom actions
You can add optional custom actions to the Info View to provide features in the Sonos app that are specific to your service. For example, custom actions for a song:
Custom actions for an album:
Custom actions include the following:
Custom Action | Example | Description |
---|---|---|
Show album information | Album Info | Displays a list of all the songs of an album. For example, this displays when browsing or playing a track. |
Show artist information | Browse the Artist | Displays information about the artist such as a list of albums, depending on your service offerings. |
See related text | About the Artist | Displays text information related to the current itemType such as comments or other descriptions about it. To provide formatted and complex content, see the Open URL custom action. |
Browse to related item | Related Songs | The listener can browse your service's content that you determine is related to the current item. |
Play related item | Start Radio | The listener can play a radio stream that you determine is related to the current item. |
Open URL | Concerts | The listener can open a URL in a browser or app to provide rich related information. |
Make an HTTP Request | Save to My Acme Music | Sonos can make an HTTP REST request to your service. For example, use this to implement favorites as described in the separate tutorial, Add favorites. |
Edit playlist | Add Song to My Playlist | Providing your own playlists require more complex implementation than the other custom actions. See Add playlists for details. |
You can implement many custom actions but be aware that the listener may have to scroll the Info View. Provide custom actions dynamically, depending on the context of the current itemType
. For example, if you do not have any content for a related browse action, do not provide it for that Info View. Legacy desktop controllers do not display open URL or HTTP request actions.
Adding custom actions involves the following key tasks: provide the Info View display text and implement getExtendedMetadata responses.
Provide the Info View display text
Create a localization file with the text strings, such as an i18next file, and upload the file to your Integration Submission form. See Localization for details. The text values in your i18next file for the examples above might look like the following. Sonos provides default text strings for some custom actions.
{
"en-US":{
"common":{
...
},
"integration":{
"ABOUT_ARTIST": "About the Artist",
"RELATED_SONGS": "Related Songs",
"START_RADIO": "Start Radio",
"CONCERTS": "Concerts",
"SAVE_MUSIC": "Save to My Acme Music",
...
}
},
}
Implement getExtendedMetadata responses
Your getExtendedMetadata responses for custom actions need to include XML elements indicated in the table below. See the related section for implementation details.
Custom Action | Key XML Elements | Section |
---|---|---|
Show album information | trackMetadata & albumId | Album & artist |
Show artist information | trackMetadata & artistId mediaCollection & artistId | Album & artist |
See related text | relatedText | Related text |
Browse to related item | relatedBrowse | Related browse |
Play related item | relatedPlay | Related play |
Open URL | relatedActions action actionType & openUrl openUrlAction | Web page |
Make an HTTP Request | relatedActions action actionType & simpleHttpRequest simpleHttpRequestAction | REST request |
Updated 3 months ago