I might be missing something, but it doesn’t appear that there’s a built-in way to create a playlist based on local media items and feed it to a media player. I also couldn’t really find anything in the forums about doing this, so I created a quick package for it and am sharing it here.
This allows you to define a playlist as a script, storing it in an input_select, and playing each track in sequence one after another. Note that the forward / reverse buttons on your media player won’t do anything since we’re just feeding it one track at a time, so you’d need to create a button to call play_previous_track_in_playlist and play_next_track_in_playlist if you want to skip ahead or back.
This is awesome, and I agree that it’s weird that HA doesn’t have some kind of native playlist support.
Have you improved on this in the year since you posted it? Got it working, but seems onerous to set it up for individual media players, could maybe create a “Target Media Player” dropdown, that dynamically sets the media_player in the Play Playlist, Play Previous/Next Track in Playlist scripts.
Also, maybe it’s a Roku thing, but for an MPD (and likely other media players), I set the media_content_type to music, not url as in your script(s).
Again, thanks for this. Hopefully we don’t have to create work-arounds like this for much longer and actual playlists will be supported.
I ended up abandoning this because Roku removed the ability (in their 11.5 update) to use the Play on Roku app to play URLs which broke my script. I’m glad you got it working by changing the media_content_type, though I’m not really sure how it works, since I’m assuming Home Assistant is still just passing along a URL when you do that.
I switched to running a Plex server on my PI and using the Plex app on my Roku TV. I have a script that just passes the desired album name to the Plex media player; that way I have a true playlist and the previous / next track buttons work properly.
Can you share this script for the plex server? I have been running plex server on a pi but only have been using it to play music over my pc via the browser. I wish to stream music over a media player I have setup using esphome.