Announcements

Help Wizard

Step 1

NEXT STEP

Can't resume playback, can only play a new track (player/play API endpoint)

Can't resume playback, can only play a new track (player/play API endpoint)

pressPlay(token, device_id) {
const path = 'https://api.spotify.com/v1/me/player/play?device_id=' + device_id;
axios({
method: 'put',
url: path,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + token
}
})
}

playTrack(token, device_id) {
const path = 'https://api.spotify.com/v1/me/player/play?device_id=' + device_id;
axios({
method: 'put',
url: path,
data: {
"context_uri": "spotify:album:5ht7ItJgpBH7W6vJ5BqpPr"
},
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + token
}
})
}

pressPlay() doesn't work when no data is provided. Hence I can't resume playback of the current track. A 403 error is returned.  playTrack() works fine when a track is provided in the data field. When i provide data as {} or null, these also return server errors. How do I resume playback of the current track?

Reply
1 Reply

Nevermind, the endpoint works as expected when a track is actually playing then paused.

Suggested posts