Announcements

Help Wizard

Step 1

NEXT STEP

PUT /me/player/play with ordered uris array does not reliably start first URI

PUT /me/player/play with ordered uris array does not reliably start first URI

Plan

Premium

Country

United States 

Device

Samsung Galaxy A54

Operating System

Android

 

My Question or Issue

 

Hi,

I’m developing a personal Android application that controls Spotify playback using the Spotify Web API and Spotify App Remote.

The application creates its own ordered list of tracks and sends that order to:

PUT /v1/me/player/play

using an uris array, for example:

 

 
 
{
"uris": [
"spotify:track:TRACK_1",
"spotify:track:TRACK_2",
"spotify:track:TRACK_3",
"spotify:track:TRACK_4"
]
}
 

The request succeeds (2xx/204), but Spotify does not reliably begin playback with TRACK_1.

For example, in one test I sent an ordered list of 155 tracks where the first URI was the track Sister Christian. The API request succeeded, but Spotify App Remote immediately reported Sunglasses At Night, another track from the supplied list, playing at position 0.

I have reproduced this with much smaller arrays as well, including arrays containing only three tracks. Sometimes Spotify starts the first URI; other times it starts another URI from the supplied array.

Spotify's native Shuffle setting is OFF during these tests.

As a workaround, after the list request succeeds I wait approximately 300 ms and issue another:

PUT /v1/me/player/play

containing only the intended first track.

That reliably starts the correct track. However, it appears that the second /play request replaces the previously supplied playback sequence. When that track reaches the end, Spotify does not naturally continue through the original URI list.

My goal is:

  1. Supply Spotify with a complete ordered list of track URIs.
  2. Specify which track in that supplied list should begin playback.
  3. Allow Spotify itself to continue through the supplied list without requiring my application to issue another playback command at every track transition.

The Web API documentation describes uris as “a JSON array of the Spotify track URIs to play.” I also see that offset can specify a starting position or URI when using a context_uri, but the documentation says offset is only available when context_uri corresponds to an album or playlist.

Questions:

  1. When /me/player/play is called with only an uris array, should Spotify normally begin with uris[0] when Shuffle is off?
  2. Is there a supported way to specify the starting item within an arbitrary uris array?
  3. Is offset intentionally unsupported when using uris instead of context_uri?
  4. Is there another recommended way to provide Spotify with an application-generated ordered queue and have Spotify continue through it autonomously?
  5. Is there a documented or practical maximum number of track URIs that can be supplied in one /me/player/play request?

Environment:

  • Android application
  • Spotify Premium
  • Spotify Web API
  • Spotify Android App Remote for playback-state monitoring
  • user-modify-playback-state authorization
  • Native Spotify Shuffle: OFF

I can provide request bodies, track URIs, timestamps, and App Remote logs from reproducible tests if useful.

Thanks.

Reply
0 Replies

Suggested posts

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 5 years ago  in Social & Random