From b2fef52d384712ba8bea4d2409637c7582abcc69 Mon Sep 17 00:00:00 2001 From: Filip Lindqvist Date: Sat, 5 Feb 2022 21:26:03 +0100 Subject: [PATCH] Update README --- README.md | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 148861e..c663531 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,34 @@ # Getting started ## Installation -``` +```bash npm i --save spotify-web-playback-ts -``` \ No newline at end of file +``` + +## Usage +```js +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](https://developer.spotify.com/documentation/web-playback-sdk/quick-start/) + +2. Read the [Spotify Playback SDK API reference](https://developer.spotify.com/documentation/web-playback-sdk/reference/#api-spotify-player) + +3. See [SpotifyPlayer type insterface](./src/index.ts) for usage