Player

open external class Player(options: PlayerInit)(source)

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

Link copied to clipboard
constructor(options: PlayerInit)

Functions

Link copied to clipboard

Some browsers prevent autoplay of media by ensuring that all playback is triggered by synchronous event-paths originating from user interaction such as a click. This event allows you to manually activate the element if action is deferred or done in a separate execution context than the user action.

Link copied to clipboard
open fun addListener(event: String, cb: ErrorListener)

Create a new event listener under event event of type ErrorListener in the Web Playback SDK. Alias for Spotify.Player#on.

Create a new event listener under event event of type PlaybackStateListener in the Web Playback SDK. Alias for Spotify.Player#on.

Create a new event listener under event event of type PlaybackPlayerListener in the Web Playback SDK. Alias for Spotify.Player#on.

Link copied to clipboard
open fun connect(): Promise<Boolean>

Connect our Web Playback SDK instance to Spotify with the credentials provided during initialization.

Link copied to clipboard
open fun disconnect()

Closes the current session our Web Playback SDK has with Spotify.

Link copied to clipboard

Collect metadata on local playback.

Link copied to clipboard
open fun getVolume(): Promise<Number>

Get the local volume currently set in the Web Playback SDK.

Link copied to clipboard
open fun nextTrack(): Promise<Unit>

Skip to the next track in local playback.

Link copied to clipboard
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.

Link copied to clipboard
open fun pause(): Promise<Unit>

Pause the local playback.

Link copied to clipboard

Switch to the previous track in local playback.

Link copied to clipboard
open fun removeListener(event: String)

Remove all event listeners registered under a specific event type in the Web Playback SDK. Please use SpotifyWebPlaybackEvent.spotifyId to get web playback events' spotify ids

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. Please use SpotifyWebPlaybackEvent.spotifyId to get web playback events' spotify ids

open fun removeListener(event: String, cb: PlaybackPlayerListener = definedExternally)

Remove a specific PlaybackPlayerListener registered under event type event in the Web Playback SDK. Please use SpotifyWebPlaybackEvent.spotifyId to get web playback events' spotify ids

Link copied to clipboard
open fun resume(): Promise<Unit>

Resume the local playback.

Link copied to clipboard
open fun seek(pos_ms: Number): Promise<Unit>

Seek to a position in the current track in local playback.

Link copied to clipboard
open fun setName(name: String): Promise<Unit>

Rename the Spotify Player device. This is visible across all Spotify Connect devices.

Link copied to clipboard
open fun setVolume(volume: Float): Promise<Unit>

Set the local volume for the Web Playback SDK.

Link copied to clipboard
open fun togglePlay(): Promise<Unit>

Resume/pause the local playback.