Controll API. How play music from mp3 file

  • 11 January 2019
  • 3 replies


From a few days I knowing Sonos controll API form
Actualy I did it auth process as well, and now I just to try play mp3 file form HD using Sonos API. Unfortunately i can't find simply way to play any mp3 file using API.
Could someone show me simply way to do it ? Only what I'm found this is play from url
But this means, each file first should be must upload to service and next play. I'm wondering how it is working on my Sonos application in Android. There I can just choice file from my phone and play. I would like this same results. It is possible using this API ?

Best answer by controlav 12 January 2019, 17:04

View original

This topic has been closed for further comments. You can use the search bar to find a similar topic, or create a new one by clicking Create Topic at the top of the page.

3 replies

Userlevel 7
Badge +22
Sonos players cannot magically read your HD to play your mp3, so you will need to expose the file via https, either by copying it to the cloud or running a simple http server on your PC. The latter is how the Android app exposes music from your phone to the Sonos players.
I understand. Now it's all clear. Thank You for reply
I was solving quite similar problem. I didn't call API directly (instead I was using SoCo library to send commands to the Speaker), but also had to find a way to upload a file to Sonos to play it. Eventually I ended up with a solution that launches a simple HTTP server which serves the file I need to play. If you are interested, the code in Python is here:

Currently it doesn't stop working after the file is finished playing: it's probably necessary to poll the speaker's state in order to catch this moment and stop the streaming service, but now it can only be stopped manually.