Announcements

Help Wizard

Step 1

NEXT STEP

State conflict when integrate web-playback-sdk and Player API

Solved!

State conflict when integrate web-playback-sdk and Player API

I integrated playback SDK with Player API in my side project, mostly is functional
but when i playing music on local initialized playback and click set repeat mode button.

It would trigger error (technically, no error coz API response is 2xx).

API i called is following order

/me/player/repeat with device Id and state=context

endpoint would return 204 (That expected because it async command nature of Spotify API)

but it also auto called below API from Playback SDK

/track-playback/v1/devices/:deviceId/state
/track-playback/v1/devices/:deviceId/state_conflict

And after that, player repeat mode just get rollbacked to before.

How can i fix it ?

Attached is HAR captrued from network console. you can take a look first 2 ~ 5 entries.
 
OS: MacOS
Browser: Latest Chrome
 
Reply

Accepted Solutions
Marked as solution

Hey David,

Glad to read you were able to fix the issue!

Thanks a lot for your feedback. We have updated the example with the correct values:
https://developer.spotify.com/documentation/web-playback-sdk/reference/#object-web-playback-state

I have also forwarded your suggestion to the corresponding team 🙂

Cheers

View solution in original post

3 Replies

Hey David,

 

I couldn't replicate the issue. I also see the "state_conflict" message but the repeat state is correctly set according to the following API calls. Note that I'm not sending the "device_id" as query parameter, so it will use the user’s currently active device as the target:

/me/player/repeat?state=context // repeat current context
/me/player/repeat?state=track   // repeat current track
/me/player/repeat?state=off     // turn off repeat mode

 

Be aware that the repeat state does not work as a toggle. If you want to turn it off, you must send the "state=off" parameter.

 

Hope it helps!

 

Hi Alvaron , 

Turn out i find that the error is come from my code there.

 

https://github.com/davidNHK/spotify-music-player/blob/25c24f64b575e70b8e36d6ad9ae2baffcfcf9ea6/syste...

 

the "context" repeat state is 1 instead of 2 actually.

 

So i think it could be better if you guys can update document here. about the repeat_mode number

https://developer.spotify.com/documentation/web-playback-sdk/reference/#object-web-playback-state

it stated "1" is "once-repeat"

 

Of course , it would more more ideal if the response can just follow /me/player API.

https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-information-about-the-us...

 

it just return string instead.

 

Thanks for your quick reply!

Marked as solution

Hey David,

Glad to read you were able to fix the issue!

Thanks a lot for your feedback. We have updated the example with the correct values:
https://developer.spotify.com/documentation/web-playback-sdk/reference/#object-web-playback-state

I have also forwarded your suggestion to the corresponding team 🙂

Cheers

Suggested posts