svrooij / sonos2mqtt

:speaker: Sonos mqtt controller. Control your speakers from your mqtt server. mqtt-smarthome insprired.
https://sonos2mqtt.svrooij.io/
MIT License
76 stars 18 forks source link

How to play a playlist or a favorite #100

Closed dgmltn closed 4 years ago

dgmltn commented 4 years ago

How's the best way to play a playlist or a favorite (with sonos2mqtt)? Is it setAVTransportURI? But then how's the best way to list URI's of favorites/playlists?

Thanks!

svrooij commented 4 years ago

You can only play streams with SetAVTransportURI so that would work for radio stations (or Spotify artist radio). All other stuff has to be added to a queue.

The above issue was already in my head, but I'm not sure about the best solution. Looking for input.

That would give you an option to retrieve the Favorites or the queue. Then you can play those.

dgmltn commented 4 years ago

I'm coming from node-sonos-http-api and found that listing favorites is a specific "browse" command, but I guess that's not the problem.

https://github.com/jishi/node-sonos-discovery/blob/e114cb1267561307405f76a3d7ec106880cb7274/lib/prototypes/SonosSystem/getFavorites.js

But on there you can also tell it to play a favorite based on the name of the favorite. That's nice. In that case you might not even have to give output anywhere, since a user would know the name of his favorite.

This is how it plays a favorite. It handles radio stations as a special case. Makes sense.

https://github.com/jishi/node-sonos-discovery/blob/e114cb1267561307405f76a3d7ec106880cb7274/lib/prototypes/Player/replaceWithFavorite.js

svrooij commented 4 years ago
Screenshot 2020-06-10 at 21 50 04

This is the first try.

dgmltn commented 4 years ago

But once you've "GetFavoriteRadioStations" or (how do you enumerate Sonos playlists?), can you give an example of how to replace the queue with one of the playlists you've found?

svrooij commented 4 years ago

The documentation of this library wasn't up-to-par. I've made some big improvements to it, see #102

And the resulting documentation on https://svrooij.github.io/sonos2mqtt/ Your question should be answered here

dgmltn commented 4 years ago

Great update, thanks!