TypeScript Wrapper for Spotify Playback SDK
npm i --save spotify-web-playback-ts
async function load() {
const accessToken = '...'
// Init playback SDK by adding async script to document and await load
const player = await SpotifyPlayer.init(document, 'Browser Player!', 0.5, cb => cb(accessToken))
// Connect the player
await player.connect()
// Listen to player state
player.onPlayerStateChanged(state => console.log('State changed', state)
// Toggle playback
await player.togglePlay()
}
load()
-
Read the Spotify Playback SDK Quickstart
-
Read the Spotify Playback SDK API reference
-
See SpotifyPlayer type insterface for usage