ClientPlayerApi

These endpoints allow for viewing and controlling user playback. Please view the official documentation for more information on how this works. This is in beta and is available for premium users only. Endpoints are not guaranteed to work and are subject to change!

Api Reference

Constructors

Link copied to clipboard
constructor(api: GenericSpotifyApi)

Types

Link copied to clipboard

What state the player can repeat in.

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
suspend fun addItemToEndOfQueue(uri: PlayableUri, deviceId: String? = null)

Add an item to the end of the user’s current playback queue. Please note that all items in the queue will be played before resuming the current playlist/album playing, if there is one.

Link copied to clipboard
suspend fun getCurrentContext(additionalTypes: List<CurrentlyPlayingType> = listOf( CurrentlyPlayingType.Track, CurrentlyPlayingType.Episode ), market: Market? = null): CurrentlyPlayingContext?

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

Link copied to clipboard
suspend fun getCurrentlyPlaying(additionalTypes: List<CurrentlyPlayingType> = listOf( CurrentlyPlayingType.Track, CurrentlyPlayingType.Episode ), market: Market? = null): CurrentlyPlayingObject?

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

Link copied to clipboard
suspend fun getDevices(): List<Device>

Get information about a user’s available devices.

Link copied to clipboard
suspend fun getRecentlyPlayed(limit: Int? = api.spotifyApiOptions.defaultLimit, before: String? = null, after: String? = null): CursorBasedPagingObject<PlayHistory>

Get tracks from the current user’s recently played tracks. Note: Currently doesn't support podcast episodes.

Link copied to clipboard

Get the list of objects that make up the user's queue.

Link copied to clipboard
suspend fun pause(deviceId: String? = null)

Pause playback on the user’s account.

Link copied to clipboard
suspend fun resume(deviceId: String? = null)

Resumes playback on the current device, if deviceId is not specified.

Link copied to clipboard
suspend fun seek(positionMs: Long, deviceId: String? = null)

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

Link copied to clipboard
suspend fun setRepeatMode(state: ClientPlayerApi.PlayerRepeatState, deviceId: String? = null)

Set the repeat mode for the user’s playback. Options are PlayerRepeatState.Track, PlayerRepeatState.Context, and PlayerRepeatState.Off.

Link copied to clipboard
suspend fun setVolume(volumePercent: Int, deviceId: String? = null)

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

Link copied to clipboard
suspend fun skipBehind(deviceId: String? = null): String

Skips to previous track in the user’s queue.

Link copied to clipboard
suspend fun skipForward(deviceId: String? = null): String

Skips to the next track in the user’s queue.

Link copied to clipboard
suspend fun startPlayback(contextUri: ContextUri? = null, offsetIndex: Int? = null, offsetPlayableUri: PlayableUri? = null, playableUrisToPlay: List<PlayableUri>? = null, deviceId: String? = null)
suspend fun startPlayback(artistId: String? = null, playlistId: String? = null, albumId: String? = null, showId: String? = null, offsetLocalTrackId: String? = null, offsetTrackId: String? = null, offsetEpisodeId: String? = null, offsetIndex: Int? = null, trackIdsToPlay: List<String>? = null, localTrackIdsToPlay: List<String>? = null, episodeIdsToPlay: List<String>? = null, deviceId: String? = null)

Start or resume playback.

Link copied to clipboard
suspend fun toggleShuffle(shuffle: Boolean, deviceId: String? = null): String

Toggle shuffle on or off for user’s playback.

Link copied to clipboard
suspend fun transferPlayback(deviceId: String, play: Boolean? = null)

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