Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Insert song into running playlist without restarting it

Insert song into running playlist without restarting it

I'm using the Web API to insert a song into the currently running playlist right after the currently playing track.

 

So at first my playlist looks like this:

 

Song A
Song B <-- Currently playing
Song C

 

Then after my API call, it looks like this:

 

Song A
Song B <-- Currently playing
Inserted Song
Song C

 

But once Song B is over, it doesn't play the Inserted Song, but instead starts from the first song again.

 

What can I do to prevent this from happening?

 

I'm using Spotify Free and I do not have shuffle or repeat enabled.

 

Edit:

Is this maybe somehow related to playlist snapshots? Like the playlist reaches the third song and the snapshot says "The third song is supposed to Song C", but then it sees the third song has been replaced with the Inserted Song in the latest version and gets confused and thus jumps back to the first song?

Reply
3 Replies

This is happening for me on the iOS Spotify app. Currently listening to "Last Christmas" for the 10th time today. If I select a song in the middle of the playlist, once it's finished it starts playing the first song in the list again. 

So for me, playing a different playlist on my iOS device then going back to the original "Christmas" playlist solved the loop issue. The up next queue refreshes to show the following song in the playlist and not the first song again. 

Okay, after adding a song to the playlist using the Web API, I can manually start another playlist and then go back to the first one so that it plays in the correct order again, but for me that defeats the whole purpose of using the Web API.

 

The only possible workaround I see is to use the GET /v1/me/player/currently-playing endpoint after adding a song to get context.uri, item.uri and progress_ms and then pass those back into the PUT /v1/me/player/play endpoint.

 

But the latter endpoint requires Spotify Premium.

 

Edit:


I just tested my workaround idea and it sort of works, but it was more complicated. You have to call GET /v1/playlists/{id} and check at which position the currently playing track is (praying that it only exists once in your playlist), then you can pass this to the afore-mentioned premium endpoint:

 

{
    context_uri: context.uri,
    offset: { position: calculatedPosition },
    position_ms: progress_ms
}


This will cause playback to stop for a second and then resume.

I sure hope this is gonna get fixed soon. That workaround is unreasonably expensive imo.

Suggested posts

Type a product name