Skip to main content
Version: 5.1.1

Player

GetDevices

Get information about a user’s available devices.

Parameters

NameDescriptionExample

Usage

AvailabeDevices devices = _spotify.GetDevices();
devices.Devices.ForEach(device => Console.WriteLine(device.Name));

GetPlayback

Get information about the user’s current playback state, including track, track progress, and active device.

Parameters

NameDescriptionExample
[market]An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking."DE"

Usage

PlaybackContext context = _spotify.GetPlayback();
if(context.Item != null)
Console.WriteLine(context.Item.Name)); //Print the current song

GetPlayingTrack

Get the object currently being played on the user’s Spotify account.

Parameters

NameDescriptionExample
[market]An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking."DE"

This is a simpler (less data) version of GetPlayback

Usage

PlaybackContext context = _spotify.GetPlayingTrack();
if(context.Item != null)
Console.WriteLine(context.Item.Name)); //Print the current song

TransferPlayback

Transfer playback to a new device and determine if it should start playing.

Parameters

NameDescriptionExample
deviceIds or deviceIdA JSON array containing the ID of the device on which playback should be started/transferred"XXXX-XXXX-XXXX-XXXX"
playtrue: ensure playback happens on new device, false: keep current playback statetrue

Usage

ErrorResponse error = _spotify.TransferPlayback("XXXX-XXXX-XXXX-XXXX");

ResumePlayback

Start a new context or resume current playback on the user’s active device.

Parameters

NameDescriptionExample
[deviceId]The id of the device this command is targeting. If not supplied, the user's currently active device is the target."XXXX-XXXX-XXXX-XXXX"
contextUriSpotify URI of the context to play"spotify:album:1Je1IMUlBXcx1Fz0WE7oPT"
urisAn array of the Spotify track URIs to play.new List<string> { "spotify:track:4iV5W9uYEdYUVa79Axb7Rh" }
offsetIndicates from where in the context playback should start. Only available when context_uri corresponds to an album or playlist object, or when the uris parameter is used.0

Usage

ErrorResponse error = _spotify.ResumePlayback(uris: new List<string> { "spotify:track:4iV5W9uYEdYUVa79Axb7Rh" });

PausePlayback

Pause playback on the user’s account.

Parameters

NameDescriptionExample
[deviceId]The id of the device this command is targeting. If not supplied, the user's currently active device is the target."XXXX-XXXX-XXXX-XXXX"

Usage

ErrorResponse error = _spotify.PausePlayback();

SkipPlaybackToNext

Skips to next track in the user’s queue.

Parameters

NameDescriptionExample
[deviceId]The id of the device this command is targeting. If not supplied, the user's currently active device is the target."XXXX-XXXX-XXXX-XXXX"

Usage

ErrorResponse error = _spotify.SkipPlaybackToNext();

SkipPlaybackToPrevious

Skips to previous track in the user’s queue. Note that this will ALWAYS skip to the previous track, regardless of the current track’s progress. Returning to the start of the current track should be performed using the https://api.spotify.com/v1/me/player/seek endpoint.

Parameters

NameDescriptionExample
[deviceId]The id of the device this command is targeting. If not supplied, the user's currently active device is the target."XXXX-XXXX-XXXX-XXXX"

Usage

ErrorResponse error = _spotify.SkipPlaybackToPrevious();

SeekPlayback

Seeks to the given position in the user’s currently playing track.

Parameters

NameDescriptionExample
positionMsThe position in milliseconds to seek to. Must be a positive number. Passing in a position that is greater than the length of the track will cause the player to start playing the next song.50
[deviceId]The id of the device this command is targeting. If not supplied, the user's currently active device is the target."XXXX-XXXX-XXXX-XXXX"

Usage

ErrorResponse error = _spotify.SeekPlayback(50);

SetRepeatMode

Set the repeat mode for the user’s playback. Options are repeat-track, repeat-context, and off.

Parameters

NameDescriptionExample
statetrack, context or off.RepeatState.Track
[deviceId]The id of the device this command is targeting. If not supplied, the user's currently active device is the target."XXXX-XXXX-XXXX-XXXX"

Usage

ErrorResponse error = _spotify.SetRepeatMode(RepeatState.Track);

SetVolume

Set the volume for the user’s current playback device.

Parameters

NameDescriptionExample
volumePercentInteger. The volume to set. Must be a value from 0 to 100 inclusive.50
[deviceId]The id of the device this command is targeting. If not supplied, the user's currently active device is the target."XXXX-XXXX-XXXX-XXXX"

Usage

ErrorResponse error = _spotify.SetVolume(50);

SetShuffle

Toggle shuffle on or off for user’s playback.

Parameters

NameDescriptionExample
shuffleTrue or Falsefalse
[deviceId]The id of the device this command is targeting. If not supplied, the user's currently active device is the target."XXXX-XXXX-XXXX-XXXX"

Usage

ErrorResponse error = _spotify.SetShuffle(false);

AddToQueue

Add an Item to the User's Playback Queue. BETA.

Parameters

NameDescriptionExample
uriThe uri of the item to add to the queue. Must be a track or an episode uri.spotify:track:7zrCVKp6x0AtolOsn2iMif
[deviceId]The id of the device this command is targeting. If not supplied, the user's currently active device is the target."XXXX-XXXX-XXXX-XXXX"

Usage

ErrorResponse error = _spotify.AddToQueue("spotify:track:7zrCVKp6x0AtolOsn2iMif");