ClientPlayerApi

class ClientPlayerApi(api: GenericSpotifyApi) : SpotifyEndpoint

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

ClientPlayerApi
Link copied to clipboard
common
fun ClientPlayerApi(api: GenericSpotifyApi)

Types

PlayerRepeatState
Link copied to clipboard
common
What state the player can repeat in.

Functions

addItemToEndOfQueue
Link copied to clipboard
common
suspend fun addItemToEndOfQueue(uri: PlayableUri, deviceId: String? = null)
Add an item to the end of the user’s current playback queue.
addItemToEndOfQueueRestAction
Link copied to clipboard
common
fun addItemToEndOfQueueRestAction(uri: PlayableUri, deviceId: String? = null): SpotifyRestAction<Unit>
Add an item to the end of the user’s current playback queue.
getCurrentContext
Link copied to clipboard
common
suspend fun getCurrentContext(): CurrentlyPlayingContext?
Get information about the user’s current playback state, including track, track progress, and active device.
getCurrentContextRestAction
Link copied to clipboard
common
Get information about the user’s current playback state, including track, track progress, and active device.
getCurrentlyPlaying
Link copied to clipboard
common
suspend fun getCurrentlyPlaying(): CurrentlyPlayingObject?
Get the object currently being played on the user’s Spotify account.
getCurrentlyPlayingRestAction
Link copied to clipboard
common
Get the object currently being played on the user’s Spotify account.
getDevices
Link copied to clipboard
common
suspend fun getDevices(): List<Device>
Get information about a user’s available devices.
getDevicesRestAction
Link copied to clipboard
common
fun getDevicesRestAction(): SpotifyRestAction<List<Device>>
Get information about a user’s available devices.
getRecentlyPlayed
Link copied to clipboard
common
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.
getRecentlyPlayedRestAction
Link copied to clipboard
common
fun getRecentlyPlayedRestAction(limit: Int? = api.spotifyApiOptions.defaultLimit, before: String? = null, after: String? = null): SpotifyRestAction<CursorBasedPagingObject<PlayHistory>>
Get tracks from the current user’s recently played tracks.
pause
Link copied to clipboard
common
suspend fun pause(deviceId: String? = null)
Pause playback on the user’s account.
pauseRestAction
Link copied to clipboard
common
fun pauseRestAction(deviceId: String? = null): SpotifyRestAction<Unit>
Pause playback on the user’s account.
resume
Link copied to clipboard
common
suspend fun resume(deviceId: String? = null)
Resumes playback on the current device, if deviceId is not specified.
resumeRestAction
Link copied to clipboard
common
fun resumeRestAction(deviceId: String? = null): SpotifyRestAction<Unit>
Resumes playback on the current device, if deviceId is not specified.
seek
Link copied to clipboard
common
suspend fun seek(positionMs: Long, deviceId: String? = null)
Seeks to the given position in the user’s currently playing track.
seekRestAction
Link copied to clipboard
common
fun seekRestAction(positionMs: Long, deviceId: String? = null): SpotifyRestAction<Unit>
Seeks to the given position in the user’s currently playing track.
setRepeatMode
Link copied to clipboard
common
suspend fun setRepeatMode(state: ClientPlayerApi.PlayerRepeatState, deviceId: String? = null)
Set the repeat mode for the user’s playback.
setRepeatModeRestAction
Link copied to clipboard
common
fun setRepeatModeRestAction(state: ClientPlayerApi.PlayerRepeatState, deviceId: String? = null): SpotifyRestAction<Unit>
Set the repeat mode for the user’s playback.
setVolume
Link copied to clipboard
common
suspend fun setVolume(volumePercent: Int, deviceId: String? = null)
Set the volume for the user’s current playback device.
setVolumeRestAction
Link copied to clipboard
common
fun setVolumeRestAction(volumePercent: Int, deviceId: String? = null): SpotifyRestAction<Unit>
Set the volume for the user’s current playback device.
skipBehind
Link copied to clipboard
common
suspend fun skipBehind(deviceId: String? = null): String
Skips to previous track in the user’s queue.
skipBehindRestAction
Link copied to clipboard
common
fun skipBehindRestAction(deviceId: String? = null): SpotifyRestAction<String>
Skips to previous track in the user’s queue.
skipForward
Link copied to clipboard
common
suspend fun skipForward(deviceId: String? = null): String
Skips to the next track in the user’s queue.
skipForwardRestAction
Link copied to clipboard
common
fun skipForwardRestAction(deviceId: String? = null): SpotifyRestAction<String>
Skips to the next track in the user’s queue.
startPlayback
Link copied to clipboard
common
suspend fun startPlayback(contextUri: ContextUri? = null, offsetIndex: Int? = null, offsetPlayableUri: PlayableUri? = null, playableUrisToPlay: List<PlayableUri>? = null, deviceId: String? = null)
Start or resume playback.
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.
startPlaybackRestAction
Link copied to clipboard
common
fun startPlaybackRestAction(contextUri: ContextUri? = null, offsetIndex: Int? = null, offsetPlayableUri: PlayableUri? = null, playableUrisToPlay: List<PlayableUri>? = null, deviceId: String? = null): SpotifyRestAction<Unit>
Start or resume playback.
fun startPlaybackRestAction(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): SpotifyRestAction<Unit>
Start or resume playback.
toggleShuffle
Link copied to clipboard
common
suspend fun toggleShuffle(shuffle: Boolean, deviceId: String? = null): String
Toggle shuffle on or off for user’s playback.
toggleShuffleRestAction
Link copied to clipboard
common
fun toggleShuffleRestAction(shuffle: Boolean, deviceId: String? = null): SpotifyRestAction<String>
Toggle shuffle on or off for user’s playback.
transferPlayback
Link copied to clipboard
common
suspend fun transferPlayback(deviceId: String, play: Boolean? = null)
Transfer playback to a new device and determine if it should start playing.
transferPlaybackRestAction
Link copied to clipboard
common
fun transferPlaybackRestAction(deviceId: String, play: Boolean? = null): SpotifyRestAction<Unit>
Transfer playback to a new device and determine if it should start playing.

Properties

api
Link copied to clipboard
common
val api: GenericSpotifyApi
cache
Link copied to clipboard
common
val cache: SpotifyCache

Sources

common source
Link copied to clipboard