Is there an API for the "play all" feature?

Is there an API for the "play all" feature?

dandan Posts: 3Member
Hi community,

is there an API for the "play all" feature that is in the SoundTouch app?

The following use case is the one I would like to improve by writing an Android Widget that I put on my homescreen:

I typically use the Spotify app to play a song, and choose "Bose Device 1" as the device to play it on. If I want to play that song on all my devices, then I need to open the SoundTouch app (several seconds of loading time), swipe to "Bose Device 1" (could take some more seconds until device is found on the WiFi and loaded inside the app), then click the "play all" button. 

Instead, I would like to choose my song inside the Spotify app, play it, and click 1 button on my homescreen widget to play it on all devices, which would save me a bunch of clicks and time.

So, is there an API available for the "play all" feature? I could discover the devices programmaticallly, call the /play_now endpoint, and if playStatus==PLAY_STATE then I trigger the "play all" endpoint? No such API is documented in the API documentation, but maybe there is an undocumented API that is available? If not, any ideas if a "play all" endpoint is being planned for?

Thanks!

Comments

  • JustAnotherUserJustAnotherUser Posts: 7Member
    From the Bose app you must select which device to "Play All" from so presume it just uses that as the master when posting /setZone and includes all others a memebrs.

    If you didn't want to check each device to find the one that's playing, could always consider one as your master device then zone from there. This means as I leave the house I can just press of off button on our entrance hall SoundTouch to kill all music.
     
    Should you be trying to target Spotify specifically, may want to look for source="SPOTIFY" in the /now_playing output as that would discount devices that were say playing a different source such as bluetooth.
  • dandan Posts: 3Member
    Dear @JustAnotherUser
    thank you so much for your answer and pointing me to the /setZone endpoint. This is highly appreciated. Also thanks for the hint wiht the master device closest to your entrance. 

  • dandan Posts: 3Member
    I would like to share the end-to-end solution I ended up with. (ping @JustAnotherUser in case you're curious)

    Since the API works with very basic HTTP calls, I did not even have to write my own Android widget. 
    Instead, I installed this simple app, called "HTTP Request Shortcuts": https://play.google.com/store/apps/details?id=ch.rmy.android.http_shortcuts

    In the app I have added a simple HTTP POST call configured like this:

    Method
    POST
     
    URL
    http://192.168.0.200:8090/setZone

    Request Body
    <?xml version="1.0" ?><zone master="MACADDRESS01"><member ipaddress="192.168.0.200">MACADDRESS01</member><member ipaddress="192.168.0.201">MACADDRESS02</member><member ipaddress="192.168.0.202">MACADDRESS03</member></zone>
    Next, I added a widget for the HTTP Request Shortcuts app on my Android phone's home screen and called it "Play All Bose". Now when I click that widget, it will play on all devices, granted that a song is playing on the master. 

    Note, that on my WiFi router I have added some static rules in the DHCP config, so that MAC address MACADDRESS01 always gets IP address 192.168.0.200, MACADDRESS02 => 192.168.0.200 and MACADDRESS03 => 192.168.0.202.

    *.200 is my master. *.201 and *.202 the slaves.

    This config will make sure that DHCP doesn't reassign the IP addresses and breaks my Widget (at least until the next reset of my router ;))

    It's a fairly basic and static setup, but it gets the job done. Hope anyone finds this helpful.

    Cheers!
  • urhanjohnurhanjohn Posts: 1Member
    Thank you very much, Dan!

    I had some struggle to get this to work. If anyone else does, here's what I had to consider:
    - the MAC address is written without colons. Use (for example) "A1B2C3D4E5F6" instead of "A1:B2:C3:D4:E5:F6".
    - the MAC address of the device my router showed me didn't work. http://ipaddress:8090/info gave me two different MAC addresses for each device, one type "SCM", one type "SMSC". I don't know the difference, but I had to use the first one.
Sign In or Register to comment.