Playback control
The SDK provides the following playback commands. For implementation details, see the API reference in splayer_controls_api-3.h.
-
Play: Start or resume playback.
-
Pause: Pause the current track.
-
Skip: Skip to the next track in the queue.
-
Set volume: Adjust the playback volume.
-
Seek: Jump to a position, in milliseconds, within the current track.
is_playing() and is_paused()
is_playing() == false does not always mean the player is paused.
This happens when a schedule is used to set periods of scheduled silence (non-active time slots). During these times, no music is supposed to play, but the player hasn't been explicitly paused by a user. In this "scheduled silence" state, both is_playing() and is_paused() will return false. Therefore, you must always check both is_playing() and is_paused() to determine the correct state of the player and update your playback controls accordingly.
State logic
Use this table to understand the player's true state based on the API responses:
is_playing() | is_paused() | Player status | UI should show |
|---|---|---|---|
true | false | Playing | Pause button |
false | true | Paused | Play button |
false | false | Not playing (scheduled silence) | Pause button |
Browsing and playing the library
To browse the account's playlists and schedules and play one of them on the connected sound zone, use the library API in splayer_library_api-1.h. Fetch the library asynchronously with fetch_library(), or with the synchronous helper fetch_library_sync(). To show what the sound zone is currently playing from, use get_current_source, and release the result with free_source. It returns the playlist or schedule assigned to the sound zone; when a schedule is assigned, it returns the schedule rather than the playlist it is currently playing.
Extending functionality with the Soundtrack API
For features the SDK doesn't provide, for example in a companion app, use the cloud-based Soundtrack API. It supports, for example:
-
Searching for specific songs or artists
-
Assigning playlists and schedules to sound zones