Skip to content

tkhduracell/spotify-web-playback-ts

Repository files navigation

spotify-web-playback-ts

spotify-web-playback-ts

TypeScript Wrapper for Spotify Playback SDK

Issues GitHub pull requests GitHub Downloads GitHub Total Downloads GitHub release

Node.js CI on Darwin Node.js CI on Ubuntu Node.js CI on Windows

Node.js Package CodeQL

Report Bug Request Feature

Systems on which it has been tested:

Macos

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