0.0.3 • Published 4 months ago

spotify-web-playback-ts v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Getting started

Installation

npm i --save spotify-web-playback-ts

Usage

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()

Documentation

  1. Read the Spotify Playback SDK Quickstart

  2. Read the Spotify Playback SDK API reference

  3. See SpotifyPlayer type insterface for usage