4

I'm using soco (link github), I'm try to playing a song on my computer by using these command :

sonos = SoCo('192.168.1.102') 
sonos.play_uri('C:\\mysong.mp3')

but it got error :

Illegal MIME-Type

Someone help me please!

hairboat
  • 650
  • 19
  • 29
tuanph
  • 41
  • 3
  • 1
    Is that the only error message? If you got a traceback, please post the full text of the traceback – Wayne Werner May 04 '15 at 17:07
  • thanks for your comment, i think it got error because function `play_uri` only recevice a `uri` not a 'path'. it show message 'not correct format'.I tried to get `uri` from a music file on computer but not success. – tuanph May 05 '15 at 09:54
  • If you paste what you tried and the exact output it's likely that someone can help – Wayne Werner May 05 '15 at 11:32
  • Did you find a solution? – Zvika Jul 20 '16 at 21:15

1 Answers1

3

The uri you provide has to be in the Sonos upnp format. The play_uri() action is run on your Sonos device, not on your PC, so it has no access to your local C: drive.

Play something using the Sonos app, and then use Python soco to look at the running device to get its uri as seen from the Sonos device.

sonos = SoCo('192.168.1.102')
sonos.get_current_track_info()

This will return a dict that includes the uri. Plug that uri in to your play_uri call.

Here are some uri's that work for me. The first is the Radio Paradise station, which should work for you. The second is an album I have on my NAS, which gives you an idea of how to play a specific cut remotely. The cut must be indexed in your Sonos music library.

sonos.play_uri('aac://http://stream-uk1.radioparadise.com/aac-320')
sonos.play_uri('x-file-cifs://192.168.1.222/SDCard_Volume1/Brian%20Eno/Thursday%20Afternoon/01.%20Thursday%20Afternoon%20(61-minute%20version).mp3')
gripsnarl
  • 53
  • 8