Sonos Music API - Getting Started Guide

Programmed radio

The program container type provides a way for a SMAPI service to deliver tracks in the fashion required by DMCA-compliant programmed radio stations.

If you want to deliver such radio stations, begin by exposing each station as it's own unique container having container type program.  Be sure to indicate canPlay=true and canEnumerate=true.

When the user initiates playback on the station, the Sonos player will call getMetadata using the program's ID, asking for some (large) number of tracks.  The purpose of this call is for the SMAPI service to provide successive segments of tracks within the station.  Typically, very short segments of 2-4 tracks would be returned by each call.

Once each segment has played to completion, the Sonos player will call getMetadata again, asking for another segment.  The SMAPI service should reply by returning a different list of tracks, per the algorithm employed to synthesize your radio track list.

In other words, when you implement a programmed radio station, the Sonos player will call getMetadata, passing in the program ID, and asking for index=0/count=100. The expected response would be a short list of tracks in a mediaList, say 4, so the returned result would have index=0/count=4/total=4.  Note you need not return a grand total - you can "lie" about how many tracks are in this segment, the Sonos player will still ask for a new segment when this one is finished.

If due to licensing or business rules, you need to prevent the user from skipping tracks in the station, be sure to set canSkip=false on each track returned by the call to getMetadata that delivers another segment.