playbackSession > suspend

This command is a new API to support suspending and resuming playback. We’ll provide more details about how to implement this feature in the coming months. Watch the blog for details.

Use the suspend command in the playbackSession namespace to suspend a specified session. The player will clear the stored item window of tracks and send a playbackStatus event to tell clients that the current item is null.

As described in a cloud queue use case in Play audio, if your app sends a play command when the cloud queue is empty, the player will attempt to resume playback of content that was playing prior to this command. For example, if the user was previously listening to a radio station or had a playlist queued, it will attempt to resume playback of that content.

When a session is suspended, the player won’t revert to the previous music source in this case. Instead, the player delivers a sessionInfo event with a suspended value of true for the suspended session. The session stays suspended until one of the following occurs:

  • The player receives a play command. If the player receives a play command, it sends a sessionInfo event with a suspended value of false.
  • The player receives either a loadCloudQueue or skipToItem command for the suspended session. The player follows these commands as specified.
  • The player receives a createSession command. The suspended session receives an ERROR_SESSION_EVICTED sessionError.
  • The user or an action picks a new music source. This can either be from the Sonos app or through the loadFavorite command. The suspended session receives an ERROR_SESSION_EVICTED sessionError.

Endpoint

POST


Request parameters

This command requires a sessionId to determine the target of the command. See the Control documentation for details.

See the table below for descriptions of parameters in the body.

Parameters Type Value
queueVersion string (Optional) The player will store this value locally. The cloud queue server should return this queue version in all GET /version and GET /itemWindow responses while the player is suspended.

Response

Returns an empty body with a success value of true if successful.

In the event of a failure, the player returns a sessionError or a globalError.

For example. if the sessionId is not valid or has terminated, the player returns an ERROR_INVALID_OBJECT_ID globalError.

Example

Request