KoljaWindeler / ytube_music_player

YouTube music player for homeassistant
337 stars 53 forks source link

Simultanous use of Cast and ytube Plugin #125

Closed drasonyx closed 3 years ago

drasonyx commented 3 years ago

First of all, let me express my thanks for this awesome integration! It is so much better than anything else I came across, handy, useful, fun to use!

I am a bit struggling however with one thing which might be a topic for an enhancement. My use-case is that I am using Youtube directly from my phone or from my Google Home via Voice Assistant. Unfortunately, the plug-in does not recognize that there is content playing on the "default speaker". Therefore it does not change any icons/album banner etc. If that was possible it would make it perfect


Below you see:

1 your integration with a playlist which I started first

2 the mini-player showing the current song playing directly from my phone youtube via cast

in #1 the progressbar is still continuing like #2, the volum works too and changes both player, play/pause the same not working is update of album/title and forward/backwards, this will jump back to my playlist set in #1 Hope this is not too crypted image

Greetings from Mannheim :)

stboch commented 3 years ago

The media_players are driven by the integration and what is playing and plays next. When you use yt music to cast that uses the Cast YouTube music app. when you use the integration home-assistant uses the default cast app. These apps are incompatible.

right now that would require knowing if a media_player is a cast device and treating it differently. In addition only YouTube app has been configured as part of the pychromecast that is used by home-assistant and it would need to be extended to support yt music cast app also I am still unaware if it properly supports the authentication needed as well.

drasonyx commented 3 years ago

Thanks for the very fast reply. Not sure if I am not understanding it correctly, but e.g. if I look in the developer tools and check the entity e.g. "media_player.workshop_speaker" I see the URL set for entity_picture. Wouldn't it be enough in this case to update the picture in the media_player card and also change the icon of the "play/pause" to the state of the media_player?

In addition, I think even checking the parameter for app_id could help to identify if the ytube_player is still connected to the output-device. Again, the functions like play/pause, volume, are working fine. It would "only" be an update of the background picture and the status of the button (play/pause).

Sorry I if I am oversimplifying and maybe not getting a far more complicated point because of which this is not a suitable idea. Cheers

KoljaWindeler commented 3 years ago

hey @drasonyx , actually ... that's not a bad idea. I have a similar usecase: My wife used to switch to her music by start casting from her phone. Sure enough, once her first track is over this integration detected the "end of track" state and resumes casting my music :D But that didn't last long. Now she pauses homeassistant (this integration) and starts casting. that even worst because the ytube_music_player will stall while the Chromecast player will continue to update (picture / time / etc).

So it was on my 2do list anyway ...

But @stboch is also correct ... the output player is usually only that .. an output. Information don't float backwards very good. A chromecast actually tells you what picture to use and most of the time also the track.

I see two options (you already pointed them out): a) update the ytube_music_players background picture, artist, album etc

b) detect the changed Application ID and switch off the ytube_music_player

As of now I tend to implement b) ... otherwise we'll always run into strange behaviors over and over ..

KoljaWindeler commented 3 years ago

Please test this beta release https://github.com/KoljaWindeler/ytube_music_player/releases/tag/20210816.01 and provide feedback

drasonyx commented 3 years ago

@KoljaWindeler thanks for the very fast implementation! Solution b) works like you described it, once I switch the source (e.g. youtube music via google cast from my phone) it stops the YTube-Player and only shows the image in the other player. It certainly avoids some confusion and strange behaviour, but not sure if I am so happy with two players in my dashboar :D I guess i need to educate my family and myself to use HA to cast music instead of their phones.. or better, have media automated. I guess this is the ultimate idea anyway :)

Thanks again! Cheers,

KoljaWindeler commented 3 years ago

that or you make some conditional card mediaplayer for chrome cast is only visible if the chromecast is on and the ytubemusic player is off else show the ytube music player :D

I'll go ahead and close this, but feel free to reopen if something isn't working as expected

drasonyx commented 3 years ago

Not sure if it is realted to the latest fix in the beta, but I am now having issues with interrupt_start / interrupt resume when I send TTS in between.

It behaves very strangely. Sometimes it plays TTS and most times it does not, but everytime (does not matter if TTS is working or not), it will not resume to the position/track and it starts a new track on interrupt_resume.