Player

open external class Player(options: PlayerInit)

The main constructor for initializing the Web Playback SDK. It should contain an object with the player name, volume and access token.

Parameters

options

The options to instantiate this Player

Constructors

Player
Link copied to clipboard
js
fun Player(options: PlayerInit)
The options to instantiate this Player

Functions

addListener
Link copied to clipboard
js
open fun addListener(event: String, cb: ErrorListener)
Create a new event listener under event event of type ErrorListener in the Web Playback SDK.
open fun addListener(event: String, cb: PlaybackStateListener)
Create a new event listener under event event of type PlaybackStateListener in the Web Playback SDK.
open fun addListener(event: String, cb: PlaybackPlayerListener)
Create a new event listener under event event of type PlaybackPlayerListener in the Web Playback SDK.
connect
Link copied to clipboard
js
open fun connect(): Promise<Boolean>
Connect our Web Playback SDK instance to Spotify with the credentials provided during initialization.
disconnect
Link copied to clipboard
js
open fun disconnect()
Closes the current session our Web Playback SDK has with Spotify.
equals
Link copied to clipboard
js
open operator fun equals(other: Any?): Boolean
getCurrentState
Link copied to clipboard
js
open fun getCurrentState(): Promise<PlaybackState?>
Collect metadata on local playback.
getVolume
Link copied to clipboard
js
open fun getVolume(): Promise<Number>
Get the local volume currently set in the Web Playback SDK.
hashCode
Link copied to clipboard
js
open fun hashCode(): Int
nextTrack
Link copied to clipboard
js
open fun nextTrack(): Promise<Unit>
Skip to the next track in local playback.
on
Link copied to clipboard
js
open fun on(event: String, cb: ErrorListener)
Create a new event listener under event event of type ErrorListener in the Web Playback SDK.
open fun on(event: String, cb: PlaybackStateListener)
Create a new event listener under event event of type PlaybackStateListener in the Web Playback SDK.
open fun on(event: String, cb: PlaybackPlayerListener)
Create a new event listener under event event of type PlaybackPlayerListener in the Web Playback SDK.
pause
Link copied to clipboard
js
open fun pause(): Promise<Unit>
Pause the local playback.
previousTrack
Link copied to clipboard
js
open fun previousTrack(): Promise<Unit>
Switch to the previous track in local playback.
removeListener
Link copied to clipboard
js
open fun removeListener(event: String)
Remove all event listeners registered under a specific event type in the Web Playback SDK.
open fun removeListener(event: String, cb: ErrorListener = definedExternally)
Remove a specific ErrorListener registered under event type event in the Web Playback SDK.
open fun removeListener(event: String, cb: PlaybackStateListener = definedExternally)
Remove a specific PlaybackStateListener registered under event type event in the Web Playback SDK.
open fun removeListener(event: String, cb: PlaybackPlayerListener = definedExternally)
Remove a specific PlaybackPlayerListener registered under event type event in the Web Playback SDK.
resume
Link copied to clipboard
js
open fun resume(): Promise<Unit>
Resume the local playback.
seek
Link copied to clipboard
js
open fun seek(pos_ms: Number): Promise<Unit>
Seek to a position in the current track in local playback.
setName
Link copied to clipboard
js
open fun setName(name: String): Promise<Unit>
Rename the Spotify Player device.
setVolume
Link copied to clipboard
js
open fun setVolume(volume: Float): Promise<Unit>
Set the local volume for the Web Playback SDK.
togglePlay
Link copied to clipboard
js
open fun togglePlay(): Promise<Unit>
Resume/pause the local playback.
toString
Link copied to clipboard
js
open fun toString(): String

Sources

(source)
Link copied to clipboard