spotify-thing-doer
v1.0.0
Published
I promise this will be fun
Downloads
2
Readme
promises-promises
Getting started
npm install
- Clone credentials files:
cp secrets.js.example secrets.js
cp player/public/token-init.js.example player/public/token-init.js
- Get token: https://developer.spotify.com/documentation/web-playback-sdk/quick-start/
- Update
ACCESS_TOKEN
inplayer/public/token-init.js
- Start player:
cd ~/workspace/promises-promises/player
node app.js
- Go to
http://localhost:3000
- Get Device ID from console (it should say "Ready with Device ID ")
- Update
ACCESS_TOKEN
andDEVICE_ID
insecrets.js
.
In REPL:
var wrapper = require('./spotify-thing-doer')
var muzak = require('./muzak');
wrapper.findTrack('Toxic', 'Britney').then(wrapper.play);
setTimeout(wrapper.pause, 5000);
Or as a consumer:
var wrapper = require('spotify-thing-doer');
Code examples
// Search with object polling
var out;
wrapper.searchWithObjectPolling('Toxic', 'Britney', out);
// wait and poll your object yourself
wrapper.play(out.track);
// Search with callback
wrapper.searchWithCallback('Toxic', 'Britney', wrapper.play);
// Search with promises
var promise;
promise = wrapper.searchWithPromises('Toxic', 'Britney');
promise.then(wrapper.play);
// Search with async/await
async function searchWithAsyncAwait() {
var track = await wrapper.searchWithPromises('Toxic', 'Britney');
wrapper.play(track);
}
// Search with fibers (using synchronize)
var sync = require('synchronize');
sync.fiber(() => {
var track = wrapper.searchWithFibers('Toxic', 'Britney');
wrapper.play(track);
});
// Make a cool Elevator Music player!
var player;
wrapper.createOneTrackSpotifyPlayer({
trackName: 'Back in Time',
artistName: 'Huey Lewis'
}).then((result) => {
player = result;
console.log('Ready!');
});
player.start()
setTimeout(player.stop, 5000);