Youtube Music - Media Browser

what card?? send to us

Iā€™ve uploaded my code to GitHub - pathofleastresistor/ytube-media-card. Itā€™s purely experimental and mostly just hacking together what I can get out of the current integration.

Currently is there any change that we can do search for a youtube music song and play the first result and then play randomly as youtube suggest?

I dont want to stick with playlist, day by day, year by year :)))

love this add-on

1 Like

Iā€™d say yes.
Havenā€™t tried, but you can call the search service call, grab the videoID of the first result and start a radio based on that track.
What have you tried so far?
Jkw

@JKW As I mentioned before, I managed to have ytube_music playing on my Sonos speaker using OwnTone as a ā€˜proxyā€™. But Iā€™m still fighting with the next track behaviour of ytube_music:
OwnTone goes to off state at the end of a track, so I set off_is_idle, which works correctly
But when I press next track on ytube_music, OwnTone goes to paused state for a moment, triggering ytube_music to also go to paused state, stopping the stream.
So I think I need an extra service call off_or_pause_is_idle for this to be handled correctly. As next track seems to work correctly when I issue a pause_is_idlecall, but then the next track on end of current track no longer works as off is then no longer detected as idle.

Then another issue I encounter: I also want to be able to play ytube music on other devices than the Sonos/OwnTone combo, but there seems to be no way to reset the the off_is_idle call. Providing an idle_is_idle call to reset the idle detection to default could be a solution to this ? Or by resetting the idle detection method whenever the ytube_music playback target is changed?

Alternatively, and perhaps more user-friendly, but probably more work :slight_smile: , would be that ytube_music keeps track of which idle detection method to use on which target.

Should I open an issue on github for this ?
Iā€™m absolutely new to home assistant and have not much python knowledge, but looking at your code, I think adding an off_or_pause_is_idle and a idle_is_idle service call to your code should lie within my current abilities, so I can try to provide a pull request for that?

What are your thoughts about this ?

I like the idea ā€¦ actually all of them.
Iā€™d say to provide a list per player might be overkill, Iā€™d rather recommend to have multiple instances of ytubemusicplayer for each playback one, if such special treatment is required.

But idle-is-idle and pause-or-off-is-idle ā€¦ sure ā€¦ why not.
Go for the pull request :wink:

Best way would be a harmonizes behavior in Homeassistent ā€¦ but hey
Jkw

I already have 4 instances (one for each house member, as we have a family account, so everyone has their own YT music account, their own playlists and music preferences (and some even become angry when YT starts giving recommendations based on music choices from other house members, so there is no sharing of accounts possible :-))
Iā€™m using custom:state-switch cards to show the correct YT music card based on currently logged in user. So adding even more instances (for each user on each target) would complicate things even moreā€¦

Meanwhile, I tried implementing paused-or-off-is-idleā€¦ but found out this is not really a solution. As OwnTone server pauses not only when next track is selected manually, but also when seeking inside a songā€¦ now triggering the next track instead of jumping to the selected position in the song. Not sure how to solve thatā€¦

Patch the ownTone integration?
Honestly ā€¦ not sure

That was my first thought also, but looking into the owntone integration, it just calls the owntone api on seek or next/prev song. It seems owntone server itself briefly goes to pause and then start playing again on its own. Hence triggering the state changes in the integration too. Where the YT music integration reacts on the temporary pause state by going into pause, in turn triggering an actual pause on the owntone server by the mediaplayer preventing it from starting to play again automaticallyā€¦
So I donā€™t see how to change that behaviour inside the owntone integration; other than possibly trying to ignore owntone state changes that happen within 5s or so.
But that would delay any relevant state change also with 5s.

Iā€™ve been tinkering with your code, and I found a solution that works for me: I added an _ignore_next_remote_pause_state variable and set it to true in async_media_previous_track, async_media_next_track and async_media_seek.
And when a state change playing to paused comes in from the remote player, it is ignored and the variable is reset to false
Result is that when next, prev or seek is performed, owntone pauses, performs the action, then starts playing again and the ytube music integration happily continues and ignores that pause state change. When I now manually press pause on the owntone card, ytube music still also correctly goes into pause.
So I think I solved it with this.

I will prepare a pull request with this.

Hi, Iā€™ve scrolled through this and so many other pages and canā€™t seem to find anyone that gets as far as i have, without doing steps I have not yet seen (thatā€™s confusing)ā€¦ my process has been simple to this point (too simple) and probably the reason Iā€™ve not got passed it in weeks.

So hereā€™s the steps:

  1. Download YouTube music player from the HACS storeā€¦ ā†’ Refresh ā†’ Yay
  2. Add integrations - it gives me a URL, I go to it, confirm code, login, allow, sweet ā†’ done, and go back and click submit:

[it will only let me post one screenshot, have to delete this one and iā€™ll show the last one, but this is the screen with the URL to open in another tab then come back]

This is where it starts getting different for me to what others appear to get. It takes me to the next screen:

[it will only let me post one screenshot, have to delete this one and iā€™ll show the last one, but this is the screen with language selection, and header file - same as below but without the error]

I confirm language, I can tick ā€œshow advance configurationā€ but that never does anything. Apart from being able to change the language to anything I donā€™t understand, my only option is submit. So I click it and then this happens:

It will not open advanced config, I never get to see any fields to enter a name, cookie text, or anything more. itā€™s as far as I can go and have to cancel and give up, go back to HACS, find it, click the menu and select ā€œRemoveā€, then restart before trying again and getting the exact same results again.

Now I apologise in advance, because I can only assume iā€™ve done something stupid on my first attempt (what else will it be right?) because Iā€™m fairly new to HA and still getting used to the dance routine before I start trying to dance the Waltz with it. Thanks in advance, youā€™re an amazing community and if you can help, that would be fantastic :wink:

Does this still work for you?

I started getting issues with tracks keeping skipping. Something in either HA, OwnTone server or YTube integration changedā€¦

For now I somehow fixed it by making YTube integration to ā€˜pauseā€™ whenever OwnTone server goes to ā€˜idleā€™ (not ā€˜pauseā€™ like your posts say), it does this every time when I change tracks. Sometimes it still skips a track (I can hear a second of a track before it skips to next one). Iā€™m not sure if OwnTone tries to hit ā€œnextā€ because YTube doesnā€™t play fast enough.

I could let OwnTone just keep on playing even if YTube is paused, because I can do all control from YTube. It complicates things that both integrations can control playback.

Also, should those commands be done once after HA start or?

Hi Jody,
this is really strange ā€¦ Iā€™ve never seen this before ā€¦
puh ā€¦ restart homeassistant? clear cache ?

Youā€™ve never configured this before, right? fresh install?
This is really strange ā€¦

Hi Kolja,
it was a new install at the beginning, but now Iā€™ve tried so many things itā€™s not anymore. Iā€™ve basically given up on it now altogether, as it was really starting to grind me. I binned off my Youtube music account and migrated playlists and everything over to spotify, and that works good for me.
Thanks

Do I need to get on my knees and beg?

Got an actual question?

Perhaps look at integrating YouTube Music via Music Assistant. It works perfectly.

1 Like

Hey guys just installed this integration, and thereā€™s no ytube_music_player_extra sensor? And I donā€™t find anything about it in the documentation. I want to show the lyrics

Hi, during the configuration you have to activate
image

and then

image

have you done this?

Thank you! For your work!
I installed it, everything is ok. However, when I try to play it on Alexaā€¦ it says something is missing, like the public tts configurationā€¦ something like that

Iā€™m reading the forum, is that right? It doesnā€™t work with Alexa?? :frowning:

I donā€™t think that Alexa can stream from an url. So no, not possible as far as Iā€™m aware.
Jkw

1 Like