Youtube Music - Media Browser

Ok and that used to work, right?
Can you describe a situation when it worked?
E.g.: “when I stream media via the spotify Integration all is well” ?
Jkw

Yes, it’s working very well.
I get lyrics when i stream music from every platform (spotify and tidal i actually use).

This is an example how i use it in lovelace:

              - type: conditional
                conditions:
                  - entity: sensor.salotto_audio_lyrics
                    state: 'on'
                card:
                  type: markdown
                  content: >-
                    ## {{ states.sensor.salotto_audio_lyrics.attributes.media_artist }} - {{ states.sensor.salotto_audio_lyrics.attributes.media_title }}
                    
                    {{ states.sensor.salotto_audio_lyrics.attributes.media_lyrics }}

I am thinking to add your media player to the list of media players i use with that integration…
Do you think it will work?

I’m trying to find the tidal integration, but can’t find it. Can you send me a link?

The tidal integration still doesn’t exists but if i play something from tidal the lyrics are shown as spotify.

could you be a bit more specific what you mean with “i play something from tidal” … are you starting it via a voice command or via an app from your smartphone or …

This is far outside of my expertise, but my understanding is that the Chromecast can start different apps. One of those apps is used by homeassistant which is what we’re using simply by sending a media_play command (via home-assistant). There might be a completely different app for streaming data from tidal.

If there is no INTERGRATION from homeassistant that is able to set title and artists then this is likely due to the app that is running and simply not possible. If there is one, then we can try to debug it and understand how the informations are sent. As of now I didn’t find a way.

JKW

edit: please read Chromecast audio - attributes for streaming radio
I’m fairly sure that we won’t get the chromecast to expose title and artist … and then again: those information are already exposed by my integration.
https://github.com/KoljaWindeler/ytube_music_player/blob/f4aeebe878f6815cc27c80bfe7b33c5f7e9b030b/package/markdown.yaml
It’s just a matter of configuring your GUI to show those…

In every way i start a streaming music on my chromecast, using the genius component, i get all the infos about the stream (artist, title and lyrics) on my lovelace UI.

But his happens only if there are right attributes in the chromecast media player. What i noticed in your component is that those attributes are sent only to the media_player.ytube_music_player and not to the chromecast media player. In this way i get those errors from the genius component.

Your markdown refers only to your media player and not to other media players and as i can see the right attributes are sent only to your media player…

This is what i see about the chromecast media player when streaming music from youtube music…

Schermata 2021-01-06 alle 11.21.55

And this when streaming from spotify or tidal:

Schermata 2021-01-06 alle 11.23.49

Can you show me an example about how to configure the GUI to have artist and title also on other media player than yours?

I don’t think that this is possible

Hey JKW, any plans to add the ability to like and dislike songs?
This current setup works perfectly for me thanks very much for all you work.

1 Like

Thanks for all that incredible job!!!

I want to do something near this ,and i do not find the solution:

1: play my playlist on my Google Home group with the good volume (this is ok thanks a lot again)
2: on trigger, pause the playlist like you (grab the current media_position of the track)
3: play a local source like dingdong.mp3 or thedoorisopen.mp3 on my Google Home group with a max volume.
4: start the same track of the same playlist at the same position with the same initial volume

thanks a lot if you’ve got some ideas:

1 Like

Hi @heartkingz please check https://github.com/KoljaWindeler/ytube_music_player/issues/38#issuecomment-755697430
this MIGHT add support for sonos

Hi, yes I thought about it some time ago, when there wasn’t a media_browser or shortcuts.

The big issue is that it would require an extra button or some new services, added to the media_player domain. The button should in theory be possible, but is certainly complex and bulky.

Your post made me think again … what about sort-off hijacking the media_player.select_source function with some special arguments. Usually the function is used to select the output player. But what about adding the special parameter “rate_thumb_up” / “rate_thumb_down” or so ?

One could add shortcut buttons to the mini-media-player, calling (type: source, id: rate_thumb_up) with a nice mdi icon like thumb-up and thus provide that function inside the player …

Only drawback … well technically two … 1.) there is no way to see that the song was already rated … nothing like “once you click on thumbs-up, the icon will be bold” or so … and 2.) your media player can no longer be named “media_player.rate_thumb_up” :smiley:

i totally get the use_case, but never figured out a good way.

  • getting the media_position is possible,
  • getting the type/id which were used when the player was started as well …

but there is no way to select the track inside the playlist …
in theory one could call next_track often enough to get back to the original track … but that would have terrible performance :slight_smile:

I’ll keep thinking :slight_smile:

1 Like

I’v tried a lot of things and the better one for the moment

1: pause the ytube_music_player
2: store speakers_group volume level on input number
3: set volume max on speakers_group
4: play ding_dong.mp3 on speakers_group

5: the ytube_music_player play himself the next track of the playlist

5: set a delay for the duration about dingdong.mp3
6: set volume of speakers_group to initial with input number value
7: use previous track

Thanks a lot

Hi, I’ve pretty much spend all day and got fairly far …(as always: there is a but, at the end)

My idea was to extend the media_player to support more commands instead of hijackings existing ones. That would just confuse others. I’ve added a service called ytube_music_player.call_method.
That service will support (at some point in the future) a variety of ytube specific commands … two will be interesting for you:

  • interrupt_start
  • interrupt_resume

interrupt_start - will stop the playback, store the position in track and un-subscribe from the remote_player
interrupt_resume - will resume the playback. Basically start the playback and seek to the old position … (which is a bit … jumpy… sometimes one can here the first 100ms or so before the seek happens. I was able to overcome this with setting the volume to 0 for before the command and reset it right after the command)

This is the script that I’ve tested … and it looks like it is doing the trick

alias: dingdong
sequence:
  - service: ytube_music_player.call_method
    entity_id: media_player.ytube_music_player_cf
    data:
      command: interrupt_start
  - variables:
      vol: '{{ state_attr("media_player.keller_2", "volume_level") }}'
  - service: media_player.volume_set
    entity_id: media_player.keller_2
    data:
      volume_level: 1
  - service: media_player.play_media
    entity_id: media_player.keller_2
    data:
      media_content_id: 'http://192.168.2.84:8123/local/dingdong.mp3'
      media_content_type: music
  - delay: '00:00:02'
  - service: media_player.volume_set
    entity_id: media_player.keller_2
    data:
      volume_level: 0
  - service: ytube_music_player.call_method
    entity_id: media_player.ytube_music_player_cf
    data:
      command: interrupt_resume
  - service: media_player.volume_set
    entity_id: media_player.keller_2
    data:
      volume_level: '{{vol}}'
mode: single

The BUT is that I didn’t find a way to add services to a component that is loaded with the setup_platform method. It works fine with the async_setup_entry method. The drawback is that yaml configuration calls the setup_platform method and only the storage configuration calls the async_setup_entry … at least thats what it looks like to me.

All that isn’t a deal-breaker, it only means that the config_flow needs more care to be as complete as the yaml configuration and that most user will suddenly see a second player:

  • One from the yaml configuration that will create a media_player.ytube_media_player
  • A second one from the Storage configuration called media_player.ytube_media_player_cf (_cf for config_flow) because most user will have done the inital configuration via config_flow (I assume) … and that config flow will create a storage configuration … right now it is only used to create the cookie file.

After all the storage configuration offers many advantages e.g. like loading without restarting and moving towards storage configuration was a long term goal anyway.

It would be best if all user would (slowly) move their YAML config into the storage (via ‘options’ in integration) and delete the yaml config after that. Otherwise it can get really messy with two players basically doing the same thing. The storage based player will still use the same dropdowns if you like them. If you always use hard-coded links or the media_browser you can already delete those inputs.

All that isn’t applicable now, but will be with the next version.
JKW

2 Likes

Thanks! I will test this weekend when I have time and will report back.

I will test too !! thanks for this job :love_you_gesture:

Is there a special step for getting the playlists to show up under “Media Browser”? I have installed and reinstalled using HACS and everything seems to work, but Media Browser tab looks like this

Thanks for the work! This is awesome.

The magic step is to select the ytube_music_player instead of the Webbrowser

1 Like

Is there a way to work without a premium youtube account?