Announcements

Spotify API can play a playlist but not a track

Reply

Spotify API can play a playlist but not a track

kingofsquirrel3
Music Fan

Hello, so I have some code to play a spotify playlist on my device.

The Problem is if I copy the Spotify URI of a playlist, everything works fine. But if I copy the spotify URI of a track, I get an error saying Could not find this Context URI.

(In case anyone is wondering I am using the npm package spotify-web-api-node).

 

My Code to play:

spotifyApi.play({
    context_uri: 'just go to your playlist and do share => copy Spotify URI',
    device_id: 'the id of my device',
});
1 Reply

Re: Spotify API can play a playlist but not a track

Hubo
Rock Star 16
Rock Star 16

Hey @kingofsquirrel3, the calvary's here!

 

Hmm, I've taken a look here. It looks like you're trying to set a Track URI as context.

 

The context URI is basically the URI of the item (playlist/album) that contains the track and makes sure there's content to play after the track has finished (and people can rewind and skip).

 

You can specify a context URI together with 'offset' to play a specific track from an album or playlist. Read more about this here: https://developer.spotify.com/console/put-play/.

 

If you don't have a context; I recommend using the album URI as context and set the 'offset' to 'track_number'.

 

Let me know if that clears things up.

 

Have a great day,
Hubo

HuboRock Star 16
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.
SUGGESTED POSTS