fondberg / spotcast

Home assistant custom component to start Spotify playback on an idle chromecast device as well as control spotify connect devices
Apache License 2.0
683 stars 98 forks source link

[Feature Request] Spotify Casting capabilities in the media browser. #233

Closed rako77 closed 2 years ago

rako77 commented 3 years ago

I want to make a feature to allow Spotify to cast to Chromecast devices from the media browser.

I'm willing to do the brunt of the dev work on this. I think the best place for a feature like this is in the official Spotify integration but as an unofficial Spotify API like the token you need to cast to a Chromecast device is unlikely to make it into home assistant core, I think this plugin is the best place to do the work.

I am unfamilia with the media browser API but as this plugin can call the official plugin I hope this as easy registering spotcast as a media source for Chromecast devices and then just using a shim and have official Spotify plugin to show the media browser. I realise it might be a lot more complicated then this but I think I would like to give it a try anyway.

Firstly I would like your blessing that you would accept a PR that does this.

Secondly I would like to use this thread to discuss implementation details.

fondberg commented 3 years ago

Hi!

sounds interesting. Can you point to some docs on that API?

fondberg commented 3 years ago

@rako77 can you elaborate?

skank01 commented 3 years ago

This would rock !

skank01 commented 3 years ago

Hi!

sounds interesting. Can you point to some docs on that API?

I dont think theres an api for media browser Media browser is part of HA Not sure if @rako77 is willing to elaborate, since theres no reply here

skank01 commented 3 years ago

Since new people are joining further development here, is this on the road, i think many people wants this. I find it still strange this hasnt been on developemnt ages ago (no offence meaning you guys dont progress hard enough. All respect in what you guys are doing. Take your needed time !

gmcmicken commented 3 years ago

@rako77 You could probably prototype this using "universal media player" and an input_select helper.

fcusson commented 2 years ago

@rako77, @gmcmicken

I was thinking about this request and i think a good place to start would be the xbox integration. It does have a media source browser xbox integration dir.

Home assistant does have a library in media_player that can be accessed with

from homeassistant.components.media_player import BrowseMedia

I'll start exploreing the possibilities. I think we must try to get our hand on the documentation for BrowseMedia first

emontnemery commented 2 years ago

The official Spotify integration now has media browsing support: https://github.com/home-assistant/core/pull/64921

This is essentially what's needed in the cast media_player to add support there: https://github.com/home-assistant/core/commit/deb196af36e3bba012a5becca764e2ac6bda7252

Would it make sense to allow spotcast to add some hooks in the cast media player to enable spotify support there, for example allow registering a root node for media browsing + support for playback to achieve the same things as what's added by the linked commit?

fcusson commented 2 years ago

thank you @emontnemery, good thing that it was added upstream. I was working on a proof of concept on my side to add it to spotcast, but will probably be simpler that way.

I'm going to read on the documentation and check how the media player request could be sent to Spotcast instead of directly to the media_player itself.

gmcmicken commented 2 years ago

thank you @emontnemery, good thing that it was added upstream. I was working on a proof of concept on my side to add it to spotcast, but will probably be simpler that way.

I'm going to read on the documentation and check how the media player request could be sent to Spotcast instead of directly to the media_player itself.

Like I mentioned, I think you can combine two media players with the universal media player component and possibly do this right out of the box already.

emontnemery commented 2 years ago

Media browsing as well as support for the cast media player entity to play spotify content with help of spotcast is implemented by #294

adrianmihalko commented 2 years ago

@emontnemery is there any way to try this now? I copied the new cast.py from your PR to my spotcast directory, but I can't see anything new as media source in Media:

Screenshot 2022-02-10 at 19 52 31
emontnemery commented 2 years ago

@adrianmihalko You need Home Assistant Core 2022.2, and both spotify and spotcast integrations setup.

fcusson commented 2 years ago

@adrianmihalko , the cast module only permits you to browse media from a specific device. You can check #294 which documents how to access it (you need to open the media browser from the media player directly). We would need to implement a media_source browser, but the spotify integration doesn't seem to permit that for the moment. We are still evaluating the feasibility of that part.

emontnemery commented 2 years ago

@fcusson Oh, now I think I finally understand what you mean, you want it to be possible to browse the Spotify library also directly via the "Media" view in the frontend?

This is already possible, Home Assistant populates the media browser root depending on which player is selected 👍 Home Assistant will even add a root node for each Spotify account once this PR is merged: https://github.com/home-assistant/core/pull/66256

Note that the screenshots below is with latest dev version of Home Assistant + #294.

This is with the default in-browser player selected, only local media + cameras can be browsed: image

This is with the spotify player selected, only spotify can be browsed: image

This is with a Google Chromecast Audio player selected, everything can be browsed: image

fcusson commented 2 years ago

oh wow, thank you @emontnemery I really missed that part completely. So, I'm just waiting for fondberg to provide its review and we'll be able to merge the PR. There will be a 3.6.25 release but that will be a bug fix release to ensure compatibility with python 3.8 for certain users.

adrianmihalko commented 2 years ago

I can confirm, it works great now.

Screenshot 2022-02-11 at 16 48 45

The only thing I didn't really like in this Media player that seek is not working here (jump on the timeline where I want)?

skank01 commented 2 years ago

@fcusson Oh, now I think I finally understand what you mean, you want it to be possible to browse the Spotify library also directly via the "Media" view in the frontend?

This is already possible, Home Assistant populates the media browser root depending on which player is selected 👍 Home Assistant will even add a root node for each Spotify account once this PR is merged: home-assistant/core#66256

Note that the screenshots below is with latest dev version of Home Assistant + #294.

This is with the default in-browser player selected, only local media + cameras can be browsed: image

This is with the spotify player selected, only spotify can be browsed: image

This is with a Google Chromecast Audio player selected, everything can be browsed: image

Huh how do you do that? I can only browse my selected spotify media player, and then browse that media. If i select a cast device, it says de media is empty

What i want to be able to do is: select a mediaplayer; then chose the spotify account and then browse that media... but i cant

Also... the cameras aren there either

fcusson commented 2 years ago

Hi @skank01, to get the casting ability, you would need to manually add a file cast.py. This file is currently under review in #294 and should be available as a release soon.

For your other questions: