How could play a song in my computer soco python (sonos controller python)

十年热恋 提交于 2019-12-14 03:53:30

问题


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!


回答1:


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')


来源:https://stackoverflow.com/questions/29372297/how-could-play-a-song-in-my-computer-soco-python-sonos-controller-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!