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 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
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.
@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
YES
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
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
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!
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.
@nameswilson good, the same thing happened to me ⌠Iâd assume that you didnât hit ârefreshâ after the installation of the component, right? It seams to be necessary ⌠Iâve added that to the docu now. And yes âsettingsâ -> âconfigurationâ. Thanks for pointing out
- After youâve installed this component and restarted Home Assistant please REFRESH the page, otherwise it might not show up in the list of integrations
- Open Configuration -> Integrations -> âadd integrationâ -> âYouTube Music Playerâ
@phreaq any log messages? Iâve just updated my main system without issues ⌠The changes shouldnât have affected the wait the playlists are loaded ⌠could you try a âreinstallâ of the component in hacs?
JKW
Same problem here.
edit: excuse me, i was not really clear. I am referring to the issue that @phreaq mentioned.
I have not installed this component before, itâs a fresh install.
Playlist and Speaeker input selects stay âloadingâ.
Error in the log is:
2020-11-30 11:59:08 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up ytube_music_player platform for media_player
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity_platform.py", line 197, in _async_setup_platform
await asyncio.shield(task)
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/pi/.homeassistant/custom_components/ytube_music_player/media_player.py", line 39, in setup_platform
add_entities([yTubeMusicComponent(hass, config)], True)
File "/home/pi/.homeassistant/custom_components/ytube_music_player/media_player.py", line 71, in __init__
self._api = YTMusic(config.get(CONF_HEADER_PATH, default_header_file))
File "/srv/homeassistant/lib/python3.8/site-packages/ytmusicapi/ytmusic.py", line 96, in __init__
self.sapisid = sapisid_from_cookie(self.headers['Cookie'])
AttributeError: 'YTMusic' object has no attribute 'headers'
Hi, did you create the token file (manually or via integration flow)?
JKW
edit: this commit will check if the file exists and if not post a notification message ⌠instead of crashing âŚ
I pasted the token through the integration flow.
I also see a file in /.homeassistant/.storage called ytube_header.json with some of the contents i pasted.
I will now try your commit.
edit: changed error message:
2020-11-30 13:18:44 ERROR (SyncWorker_2) [custom_components.ytube_music_player.media_player] can't file header file at /config/headers_auth.json