Youtube Music - Media Browser

I’m using https://github.com/KoljaWindeler/ytube_music_player.
And I only download zip

As per the instructions , it say create a folder called kaco…
I am doing this wrong ?

Lee

@leeb98 - It’s a typo, I think it should be

  1. In the custom_components directory (folder) create a new folder called ytube_music_player

Right, thanks for reporting and thanks to @troy for fixing it already
Jkw

Is there a shuffle mechanism/setting when playing playlist?

Yes, exactly the same as in the gmusic player from @troy. (Currently not documented) also same defaults and should be configurable in the same way (although I didn’t test)
Jkw

@jkw @phreaq I don’t think I ever got the shuffle mode working the way I intended.

If it does work the same, here what you can try

In gmusic_player, I needed to reload the playlist after changing this.


media_player.shuffle_set
This accepts a boolean so you can only turn shuffle off/on. Tracks are shuffled when the playlist is loaded.
Default is True and shuffle_mode: 1 so playback is similar to the switch. You’ll need to reload the playlist (stop/play) for this to take effect.

To turn off shuffle from the services page:

{
  "entity_id": "media_player.ytube_music_player",
  "shuffle": False
}

Shuffle Mode
This can only be set in the package configuration file which means for now having to reboot in order to change this.

I’ll use the term “track queue” to refer to the list playing songs. This could be a “playlist” or a “station” from your music library. There are three modes:

shuffle_mode: 1 - Shuffle (Default setting)
This is the default. Tracks are shuffled first then load to the “track queue”
The shuffled queue is played in order from top to bottom. Songs only repeat when the queue has reached the end and starts over.

shuffle_mode: 2 - Random
This loads the playlist songs is the same order they are saved in your library. Tracks are then randomly selected from anywhere in the queue. Since the queue itself is not being reordered, turning shuffle off/on has immediate effect. The downside here is when playing queues with small numbers of tracks it can seem like the same songs always repeat while others hardly get played.

shuffle_mode: 3 - Shuffle Random
Tracks are shuffled first then load to the “track queue”. Tracks are then randomly selected from anywhere in the queue.

I like the way it’s working but I can see that it could be simplify. Maybe another drop down select entry that has “direct/shuffle/random/random_shuffle” in it? + Default value in case the list doesn’t exist?
Jkw

@JKW - I’m sure see you lots of room for improvement :smile: I have made several attempts to rewrite the gmusic_player following along with the developer docs (and trying to learn Python at the same time). While I was never successful I did mange to gain some understanding of how (I think) gmusic_player should have been re-written.

For example, I have some unpublished versions started (somewhere) that is based using a config_flow.

These shuffle setting (along with the default number of playlist retrieved) are a perfect candidates to be added to options_flow portion of config_flow

Hmmm isn’t this something that one would want to change dynamical?

I’m pretty much only running playlist radio on my “thumbs up” list with radon activated. So it will start with a radon song from my list and continue with something “new”.

But I’ve also added the drop-down for the playlist selection to other dashboard, so I CAN switch the playlist. My “thumbs up” list is fairly Rock-Music-filled and for breakfast I switch via an automation to a “easy listen” playlist before starting the player.

The same would be possible with the shuffle. One could have a default setting and a drop-down to switch the mode without rebooting or reconfiguration via config flow. @phreaq what’s your opinion?

Jkw

:thinking: I like were that is going… In that case I resubmit,

Can you adapt it into something similar to this?

Click here to show

From gmusic_player, here is an example of how I ideally start playback. This media_player shown is usually accessed from a wall mounted tablet

Click here to show

Edit: I should add it is possible to store these values using the options_flow and still set them dynamically. The idea is that you set your own defaults using the options_flow. Then in your automations, you would provide a new value form any setting you want to over ride. If you do not include a value in the automation - the value store using options_flow would be used instead.

1 Like

@JKW the way I use the add in, I would always have random turned on, so I don’t need to flip and back and forth.

Should I be able to find it already on HACS?

No, not at the moment. Is still consider this as alpha version. Not sure how many users are running it and how stable it works.

Works great for me but I guess some more testing and feedback is needed before it should be in the defaults of hacs.

Jkw

Ps you can of course add it as custom repository
Pps: also the pull request https://github.com/home-assistant/wheels-custom-integrations/pull/190 is still open

1 Like

YES :slight_smile:
Please update doco before official release

I have some questions about how the logic works, and I think it’s somewhere between the add in, and the API itself.

Assume I have a playlist with 20 songs from 20 different artists.

If I select that playlist as the ‘playlist’ option, and set ‘source’ to ‘playlist’, it will play the 20 songs from 20 different artists in order (unless you change you’re media_player to be random).

Whereas, if I change the 'source to ‘playlist radio’, it will randomly grab one song/artist, and base a new radio station based on that one song/artist?

Is that correct thinking?

The reason I ask is, when I play a certain playlist, with many, many songs in it (1000+), and have ‘source’ set as ‘playlist’, I only hear the more ‘recent’ songs added to the playlist, and not some of the songs that have been there for quite some time. It’s almost like it’s grabbing the last 25-35 songs only.

I took a look at the code, around the self._tracks = self._api.get_watch_playlist(videoId=r_track['videoId']), and the API has an option to pass a count, perhaps it can be used?

Hi, so first up: your explanation of “playlist” / “playlist radio” is spot on. And you’re also very likely right about the 25 song limit. I’ve created a ticket on GitHub https://github.com/KoljaWindeler/ytube_music_player/issues/10 so I won’t forget to work on this. Thanks :+1:

hey @phreaq I’ve uploaded a new version that should fix your playlist limitation.
This version will also provide the ModeSwitch option.

This is how it looks like for my UI

Changing the value of the drop down while playing will reload the list, and start over with the new settings.

JKW

2 Likes

Sorry if this is a silly question to ask but I’m stuck at this point:

"Open Settings -> Integrations -> “add integration” -> “YouTube Music Player”

By Settings do you mean “Configuration” within Home Assistant? If so, when I click on “Add integration”, YouTube Music Player isn’t listed. Is there another way to add an integration that I’m missing?

Many thanks for all the effort in getting this working! :slight_smile:

Ah I’ve just restarted HA another time and it looks like it’s appeared now! nvm

@JKW I just tried the latest build, and it seems to be hung up on ‘loading’ under the ‘playlist’ drop down. none of my playlist are coming up. tried two reboots, same issue.