New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Able to play music from Apple Music #812
Comments
|
Interesting approach. Obviously, it's Apple Music centric and uses an out-of-band mechanism that differs from the normal way that SoCo does things (entirely via Sonos players). Others will have to comment on if/how it could be added to SoCo. Music services used to be supported by SoCo, but Sonos changed the way that authentication is implemented. There is work underway in PR #763 to restore support across all services. You may be interested in testing the current code to see if it works with Apple Music? Note that with Spotify (the only service with which I have experience) it is possible to add Spotify content to Sonos Playlists and Favourites, and to initiate playback in the normal way. So, that provides limited music service support, and it's what I use at the moment. |
|
Hey @pwt, thanks for the quick answer. I don't quite understand what you mean with the normal way SoCo does things (entirely via Sonos players), but I’ve experimented around a bit this morning and came up with the following: I’ve gone through some code, especially through this package here from jishi https://github.com/jishi/node-sonos-http-api because it’s able to play songs from Apple Music, Spotify and Amazon Music. For every service I tried to explain how to create or find the uri which you have to pass to your sonos speakers via soco to play a certain song. Apple Music: Amazon Music: Spotify: For me the last uri worked to some degree because SoCo added the song I wanted to the queue but gave me an error which said that I cannot play this songs without a premium subscription. Maybe someone of you who has a premium subscription could experiment a bit, try those uris out and provide some short feedback. Thanks, |
I just mean that SoCo delivers all of its functionality via interactions with Sonos players, and does not call out to other APIs such as the iTunes one. However, I don't know the music service code well, so i could easily be wrong! |
|
We hacked together something like that for Spotify and Tidal in pysonos: https://github.com/amelchio/pysonos/blob/v0.0.40/pysonos/core.py#L1767-L1976 ... it allows enqueuing share URLs from those services. It is not in a shape where I plan to submit it to SoCo. |
|
But could this approach be a potential solution for the music service problem (if it turns out to be working for other services than Apple and Amazon Music) or would it contradict the way SoCo does things (because you need to call external APIs)? |
|
I do something similar for Amazon music:
This works by searching the Solr db for the songs and then just queueing them up in Sonos via SoCo and playing them. Steve |
Hey guys,
I am currently working on a Sonos skill for Mycroft AI and therefore need access to music services to play songs. Until recently I used this to control the music, but because Mycroft Skills are written in python and I don’t want extra dependencies to set up I now want to use this package.
But unfortunately I discovered that music services aren’t natively supported here, so I tried to come up with a workaround. Maybe someone else has already come up with my solution and this here is unnecessary, but after a quick search through various issues and PRs I found nothing.
When you start playing a song through the official Sonos app, then call .get_current_track_info() on the speaker and look at the uri value you get something like this: “x-sonos-http:song%3a1193700926.mp4?sid=204&flags=8224&sn=13”
I’m using Apple Music and I noticed that the number behind “3a” is in fact the ID of the played song that you get when you search for it through the iTunes Search API. So using the Search API I’m now able to play certain songs from Apple Music on my speakers by searching for the song, taking the ID, replacing the old ID with the new one and then playing the new uri on my speaker because all the other values like sid, flags and sn stay the same, at least for Apple Music.
I’ve not tested this for other services because I only have and use Apple Music and with certain IDs the song won’t play and the Sonos app shows an error that says that this song is at the moment not available or something similar, but I’ve not figured out with which song IDs this happens.
Has anyone else come up with this yet and have I just not found it then and if not, could anyone try this out with other services?
Also I’m very new to python, GitHub and developing for open source in general, so I might not be the right person to implement this, if this turns out to be of any use.
Thanks,
QW3RTZUI0P
The text was updated successfully, but these errors were encountered: