PlayerApis

class PlayerApis(client: HttpClient = HttpClient(CIO) { install(ContentNegotiation) { json() } })

Player domain API for Spotify Web API.

Covers playback state, queue, device transfer, and playback control commands.

Constructors

Link copied to clipboard
constructor(client: HttpClient = HttpClient(CIO) { install(ContentNegotiation) { json() } })

Functions

Link copied to clipboard
suspend fun addItemToPlaybackQueue(uri: String, deviceId: String? = null): SpotifyApiResponse<Boolean>

Adds an item to the current user's playback queue.

Link copied to clipboard

Gets available Spotify Connect devices for the current user.

Link copied to clipboard
suspend fun getCurrentlyPlayingTrack(market: CountryCode? = null, additionalTypes: String? = null): SpotifyApiResponse<CurrentlyPlayingTrack>

Gets the currently playing item for the current user.

Link copied to clipboard
suspend fun getPlaybackState(market: CountryCode? = null, additionalTypes: String? = null): SpotifyApiResponse<PlaybackState>

Gets the current playback state for the current user.

Link copied to clipboard
suspend fun getRecentlyPlayedTracks(limit: Int?, after: Int?, before: Int?): SpotifyApiResponse<RecentlyPlayedTracks>
suspend fun getRecentlyPlayedTracks(limit: Int? = null, after: Long? = null, before: Long? = null): SpotifyApiResponse<RecentlyPlayedTracks>

Gets the current user's recently played tracks.

Link copied to clipboard

Gets the current user's playback queue.

Link copied to clipboard
suspend fun pausePlayback(deviceId: String? = null): SpotifyApiResponse<Boolean>

Pauses playback on a Spotify Connect device.

Link copied to clipboard
suspend fun seekToPosition(positionMs: Int, deviceId: String? = null): SpotifyApiResponse<Boolean>

Seeks playback to a position in milliseconds.

Link copied to clipboard
suspend fun setPlaybackVolume(volumePercent: Int, deviceId: String? = null): SpotifyApiResponse<Boolean>

Sets playback volume percentage.

Link copied to clipboard
suspend fun setRepeatMode(state: State, deviceId: String? = null): SpotifyApiResponse<Boolean>

Sets playback repeat mode.

Link copied to clipboard
suspend fun skipToNext(deviceId: String? = null): SpotifyApiResponse<Boolean>

Skips to the next item in the playback queue.

Link copied to clipboard
suspend fun skipToPrevious(deviceId: String? = null): SpotifyApiResponse<Boolean>

Skips to the previous item in the playback queue.

Link copied to clipboard
suspend fun startResumePlayback(deviceId: String? = null, contextUri: String? = null, uris: Uris? = null, offset: Offset? = null, positionMs: Int? = null): SpotifyApiResponse<Boolean>

Starts or resumes playback on a Spotify Connect device.

Link copied to clipboard
suspend fun togglePlaybackShuffle(state: Boolean, deviceId: String? = null): SpotifyApiResponse<Boolean>

Enables or disables shuffle for playback.

Link copied to clipboard
suspend fun transferPlayback(deviceIds: DeviceIds, play: Boolean = false): SpotifyApiResponse<Boolean>

Transfers playback to one of the user's Spotify Connect devices.