thelinmichael / spotify-web-api-node

A Node.js wrapper for Spotify's Web API.
http://thelinmichael.github.io/spotify-web-api-node/
MIT License
3.1k stars 499 forks source link

Is it possible to make spotify player play some track by track uri/url ? #371

Open mihailk111 opened 3 years ago

Noelg14 commented 3 years ago

Yeah, This is what I did to get this to work. spotifyAPI is the auth'd client.

spotifyApi.addToQueue('spotify:track:4cOdK2wGLETKBW3PvgPWqT') //track URI = spotify:track: ID .then(function(data) { spotifyApi.skipToNext() .then(data => { console.log(data);}) .catch(err => {console.log(err);}); })

benjaffe commented 2 years ago

I tried this, and was not disappointed. Well done @Noelg14 🤣

Formatted a bit more cleanly:

spotifyApi
  .addToQueue('spotify:track:4cOdK2wGLETKBW3PvgPWqT')
  .then(function () {
    spotifyApi
      .skipToNext()
      .then((data) => {
        console.log(data);
      })
      .catch((err) => {
        console.log(err);
      });
  });