Announcements

Help Wizard

Step 1

NEXT STEP

multiple instances of Web Playback

multiple instances of Web Playback

Hey, 

I was wondering if the following scenario will be possible to implement, I'm assuming that yes but I have troubles creating a proof of concept, let me explain:

 

I would like to create an application which for now will play random songs from Spotify using Spotify Web Playback SDK. I want multiple users at the same time to play potentially different songs. Let's assume they will authorize with their premium Spotify accounts. I'm trying to setup a demo using this guide:

https://developer.spotify.com/documentation/web-playback-sdk/guide/
I thought that I could simply open the client in two different tabs and that will work, but in that other tab it displays the message:
Instance not active. Transfer your playback using your Spotify app.

I have noticed that in my Spotify desktop app it detects it as a different device:

Screenshot 2022-06-22 222420.png

In order to make it work on that second tab I have to switch the device, but I want to play the music on both tabs at the same time; I think that maybe in both tabs the application detects the same authorized user and maybe that is the issue and if I could authorize with another Spotify user in second tab then that will work on a single device..?

I actually created another user and gave it premium and tried to open the app in incognito tab and authorize that user but that didn't work, I got the same message. Can anybody help me with that? How can I prepare and test such scenario in local environment?

Reply
5 Replies

ok I managed to authorize 2 users at the same time properly, but I still got this message and it still detects that tab as a different device. I can only set one active device through desktop application.. is it possible to activate 2 devices through api (at the same time) and play different songs on them?

ok I am really digging in documentation, it is a little unclear to me and cannot find an answer on the internet;

 

i did the following test: logged out from spotify on my main account in desktop application, logged onto second user and guess what.. desktop application was not detecting client tab as new device and it was not possible to cast the playback into the browser!

 

 

the quick start guide https://developer.spotify.com/documentation/web-playback-sdk/quick-start/#listening-through-the-sdk mentions the following sentence: 
The Web Playback SDK needs an access token from your personal Spotify Premium account, so the first thing we need to do is to create an application. The application contains your credentials needed to request an access token.

 

does this mean it is possible to cast the playback into the browser only if you authorize with user credentials you used to create application in developer dashboard? in my case it makes no sense because I want multiple users to use the app at the same time and I want them to potentially play different stuff at the same time...

 

I randomly clicked in the description in app status:

1.png

I was hoping that maybe if I add that user, then authorize with that user in desktop and web then that will work but unfortunately it didn't...

 

Am I doing it wrong, is that even possible?

 

ok finally I managed to get it working on that second user, I guess this adding has slight input lag;

i'll try to host it in local network and just do a test on 2 different machines at the same time that will be easier;

have anybody successfully tested that guide application by using ipv4 address (not localhost) in local network? 

1.png

it looks like that npm run dev command hosts app in local network, I was able to access that web application via ipv4 access, but for some reason spotify desktop application stopped to recognize that browser tab as device.. I tried replacing all occurrences of localhost with ipv4 address in source code and in redirectUri (in dashboard) but it didnt help.. 

ok checked dev console there was one error, cannot confirm myself if that will work but I managed to find solution so I'll just post it here so other people may look it faster in the future:

https://github.com/gilbarbara/react-spotify-web-playback/issues/54
https://medium.com/swlh/how-to-make-react-js-use-https-in-development-4ead560eff10

 

good night

Suggested posts