M3U Playlists in Media Browser

I have my local music MP3 files stored locally in /media and can assess & play them just great using the media browser.
However I am struggling with M3U playlists, in that I cannot find the correct resource URL to get it to work.
My folder structure is:


in playlist.m3u I have tried the following:

#EXTINF:123,track name
#EXTINF:123,track name
#EXTINF:123,track name

with no success. Selecting the playlist.m3u just results in the word error showing in the media player.
What I have got to work is copying all the music to www/album and using

#EXTINF:123,track name

but this seems wrong, as I have to copy the music there.
(I did try a symbolic link, but it turn out HA does not support them in www for security reasons).

How should I reference the music, in the /media folder in a M3U playlist?


Have you made any progress? I’m new to HA and just managed to add my NAS music structure to the media browser with nfs. I can play any individual song, but playlists give an error:

2020-12-25 12:49:59 ERROR (Thread-12) [homeassistant.components.cast.media_player] Failed to cast media http://myip:8123/media/music/1Playlists/Christmas.m3u?authSig=[long auth key removed] from internal_url (http://myip:8123).

Please make sure the URL is: Reachable from the cast device and either a publicly resolvable hostname or an IP address.`

I’m not sure how to change the m3u, but I’m not even certain the player is finding the m3u. All of the playlist entries are in the form \\localserver\artist\album\track.mp3. I’m holding off editing the playlist files until I can figure out why it’s reporting the m3u is unreachable.

No, I’ve sadly not made any progress.
I can use the media browser to see the .m3u files, but can’t get them to work.

Same problem here. It ‘want’s’ to play m3u but it does not do anything.
I mainly needed it to loop a song, because i couldn’t get loop/repeat working in player as well.

Right, i think i know where’s the problem, or might be.
I’ve got my audio and m3u file in media folder, so:1
files: samochod.m3u and samochod.mp3 are in media/
My m3u inside is simple:


But when i go to dev tools > states, i’ve got this:

Which asks for location media/local/samochod.m3u, what is incorrect (i think) and is it possible that auth token is generated for wrong path or something? Is that a bug in HA or we all are doing something wrong?

Thanks @fryc88 you pointed me to something
I just started with HA and still struggling to accept that I can’t do a simple task (at least I thought it would be one of the simplest things to do) like streaming my local music to my google home speaker.
And I can’t believe that no one here seams to have a solution?
Well, after your tip to check the dev tools states, I figured that in my log there were 2 error messages with auth problems (even triggering the script ones) and yes the paths did not match with the one from the script.
I am using media-source://media_source/music/song.mp3
After setting it in media_dirs: one of the auth messages disappeared and the file was playing (despite the auth problem!!!) So I am inclined to believe that there are some issues in HA, but since I just started I am no where near to understand what I am doing or what is wrong here

Then I manually linked the /media folder to my music folder and the second auth message was gone. Great.
I still can’t play m3u ? Did you figure out some more ?

I’ve just checked mine, and I think /media/local is correct, as this works for playing Mp3 files.
I think the issue is, the URL taken from the M3U files, does not contain the auth string, so fails.
(This is a guess, not sure how to test / validate this).
If someone could point me in the right direction for the code that controls the M3U behaviour, I’ll try some debugging…


No news for me, still can’t get it working with new HA release :confused:

any news on this topic? I’ve currently set the media folder, and I’ve trying to play all the music under the media folder but no success and dunno how to.

Hope there is a function something like play all media (random, ordered) in the media pool.

Congratulations to myself as I’ve done the playlist for my Google Home Mini group.
I used dir2files in node-red to fetch all the files under the media folder and select the random item in the files array to play with.
There is no need for the authSig as I tried in node-red which played successfully.

Once I turn on the input boolean switch in my web interface, the node-red sends the random music to Google Homegroup, also detects the status of the media player status, and continues to play the next song.

1 Like

Looks great. Can you share the N-R flow?


As I mounted the music folder from an SMB share, I’ve mounted the folder to /config/media directly.
and the URL to outside from HA seems like /media/media/xxx.mp3
The folder in /config/ can be shared with any other docker which also accessible from the host, I mounted it in my host machine (ubuntu) with /etc/rc.local, as there is root issue in core docker.

HA Conf

    media: /config/media

Please notice that you may also need to configure the external_url and internal_url if the music doesn’t play, more info to turn on debugging logs for media_player and related components.


  1. Install node-red-contrib-dir2files in node-red, the version I installed is 0.3.0.
  2. Create the input_boolean.music_time switch button in HA -> Configuration -> Helpers.
  3. Parse the node-red code below (N-R) to your node-red.
  4. Change the media_player entity to yours.
  5. Change the JS replace funcation content in “deal with url” function to your local media folder.


  • Shuffling music / Stop playing to Google Home / Nest by toggle the music_time button.
  • Shuffling music / Stop playing by telling Google Home / Nest to turn on/off “Music Time” (google_assistant linked with HA required).
  • Stop the music playing (e.g “Hey Google, Stop”) to media_player will stop shuffling music automatically.
  • Pause the music playing (e.g. “Hey Google, pause music”) to media_player will shuffling the next song automatically.
  • Play the next song by simply calling service media_player.media_stop or media_player.media_pause

Tell google to stop playing by voice will turn off the media player, it is different with media_stop. That’s why it is no conflicts above features. The whole setup is perfect for me, hope it could solve your shuffling local music problem.

Play next song button card

type: 'custom:button-card'
  action: call-service
  service: media_player.media_stop
    entity_id: media_player.home_group
size: 50px
icon: 'hass:fast-forward'
name: Next Song


[{"id":"13ac7585.18210a","type":"tab","label":"media player","disabled":false,"info":""},{"id":"73ed9992.5411b8","type":"dir2files","z":"13ac7585.18210a","name":"","dirname":"/config/media","pathRegex":"","isRecursive":false,"findDir":false,"isArray":true,"x":340,"y":100,"wires":[["58ff70b9.a6b58"]]},{"id":"776d310e.5979f","type":"debug","z":"13ac7585.18210a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":860,"y":100,"wires":[]},{"id":"58ff70b9.a6b58","type":"random-item","z":"13ac7585.18210a","name":"","input":"payload","inputType":"msg","output":"payload","outputType":"msg","number":1,"x":510,"y":60,"wires":[["143859dc.b68516"]]},{"id":"a1220b1d.bf98d8","type":"api-call-service","z":"13ac7585.18210a","name":"","server":"f25fc2a7.50d81","version":1,"debugenabled":false,"service_domain":"media_player","service":"play_media","entityId":"media_player.home_group","data":"post_data","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":820,"y":240,"wires":[["776d310e.5979f"]]},{"id":"143859dc.b68516","type":"function","z":"13ac7585.18210a","name":"deal with url","func":"file_name = msg.payload;\nsong_title = file_name\n    .replace(\"/config/\",\"\")\n        .replace(\"media/\",\"\")\n            .replace(\".mp3\",\"\")\nfile_name = file_name.replace(\"/config/\",\"/media/\")\nmsg.post_data = {\"media_content_id\":file_name,\"media_content_type\":\"audio/mp3\"}\nmsg.post_data[\"extra\"] ={\"metadata\": {\"metadataType\":3,\"title\":song_title}}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":140,"wires":[["a1220b1d.bf98d8","776d310e.5979f"]]},{"id":"3c129312.d5241c","type":"server-state-changed","z":"13ac7585.18210a","name":"","server":"f25fc2a7.50d81","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"media_player.home_group","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"idle","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":210,"y":280,"wires":[["f4ccfdb9.d779d","776d310e.5979f"],["3c06a1df.f5ea0e"]]},{"id":"f4ccfdb9.d779d","type":"api-current-state","z":"13ac7585.18210a","name":"","server":"f25fc2a7.50d81","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.music_time","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":230,"y":200,"wires":[["73ed9992.5411b8"],[]]},{"id":"49b79303.897c5c","type":"server-state-changed","z":"13ac7585.18210a","name":"","server":"f25fc2a7.50d81","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.music_time","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":210,"y":340,"wires":[["73ed9992.5411b8"],["52d23ddf.ff4954"]]},{"id":"52d23ddf.ff4954","type":"api-call-service","z":"13ac7585.18210a","name":"","server":"f25fc2a7.50d81","version":1,"debugenabled":false,"service_domain":"media_player","service":"media_stop","entityId":"media_player.home_group","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":600,"y":300,"wires":[[]]},{"id":"3c06a1df.f5ea0e","type":"switch","z":"13ac7585.18210a","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"paused","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":420,"wires":[["73ed9992.5411b8"],["a232d975.043968"]]},{"id":"a232d975.043968","type":"api-call-service","z":"13ac7585.18210a","name":"off music","server":"f25fc2a7.50d81","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.music_time","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":650,"y":420,"wires":[[]]},{"id":"f25fc2a7.50d81","type":"server","name":"Home Assistant"}]


Also you could install the mp3 tag in N-R or something for extra data, I’m too lazy to make that just trim the file name for song title.
I’ve linked google home with HA, haven’t test if tell google to turn on the input_boolen switch if works.

Thanks! Can’t wait to plug all of this in and try it out. I have been trying for a while to find a way to implement this in HA but if N-R does it then why not?

Hi Vincent the flow is not the same as the screen capture in #11 above. I am guessing that the one in #13 is the most recent?
If my mp3 files are in /config/media/Music does the function change to:

file_name = msg.payload;
song_title = file_name
file_name = file_name.replace("/config/","/media/","/Music/")


song_title is correct, as it just replaces the string which exists in the string, if not it doesn’t matter and won’t be an error.
the “file_name =” might be something with “media: /config/media” in conf I guess, I’m sure how HA deals with the media folder but you could have a try.
the replacement function works as file_name.replace(“old string”, “new string”), so here would be always two parameters.
try something like file_name.replace("/config/media/Music/","/media/media/"), I guess the media pool url might be /media/[media pool name in HA conf]. hmmm, not sure :grinning:.

Seems like I can get the selection to move to the next track but the player does not start to play. In fact it selects the next track and then turns the player off.
Any ideas?

sry I didn’t get the meaning of “selection to move to the next track”, do you mean when 1st song ends, the N-R sends the second song to the media player (e.g. Google Home Mini) and the media player doesn’t play the 2nd song?
Make sure that you changed all the “media_player.home_group” to your media player’s entity.
the filename should not contain the “#” or special char, the media player won’t work during my testing.

Ah the special characters might be the issue. The Media Browser has no trouble playing the tracks though. Most of my tracks will have spaces and dashes and maybe other special characters in the filename.
I have selected my player entity correctly.