Media_play does not work

base_url did the trick for me as well !

Hi! Have you solved the problem?

Have I solved it?..no
Has it been solved?.. Yes - but not sure how/ why

I had HA running on a VM and this is where I experienced the issue. I decided to try HA in a docker container - and I can play audio with no issues - tried to replicate the settings on the VM - no sucess.
So I’m moving over to the container - now all I want is to be able to play more than one track at a time - but a seperate thread for that one!

This issue seems to have migrated to node red. (I’m using the addon). Now, using the cast node results in the same issue as above on the home mini, but not the home display. Another weird observation is that it creates a media_player.py error in the home assistant log just like the above. I’m not even using the media_player or home assistant or python to create the tts request! The error in node red is:

14 May 06:14:29 - [error] [cast-to-client:469f1ae.59745e4] Not able to load media:Load failed Not able to load the media.

Now I’m curious if the issue would appear on a node red instance on a machine without HA running. This occurs on standalone instances of node red on the same network.

I’m getting issues with using google cast also .

Logger: homeassistant.components.cast.media_player
Source: components/cast/media_player.py:316
Integration: Google Cast (documentation, issues)
First occurred: 09:15:23 (2 occurrences)
Last logged: 09:15:24
Failed to cast media https://r1---sn-5ouxa-h8qe7.googlevideo.com/videoplayback?expire....

using youtube integration - was working up until 2 days ago.
using duckdns and proxymanager.
On my other HA instance I am getting pychromecast issues also.

When tts casts to google assistant it uses internal url, not external url.
It failed for me for tts casting.
But it works if I set my actual external url “https://xxxx.hd.free.fr:8123” in “internal url” field (from home assistant config UI).

Looks like issue for me was that trying to cast with internal url with http ("http://192.168.1.14:8123) does not work because only https is allowed.
https://192.168.1.14:8123/xxxx is reachable (I can play the message from my browser), but then the certificate does not match so google assistant probably rejects it (in my browser I had to explicitly ignore the security error)

Setting my base url to my https duckdns url under tts in the config file did not work. I still get the same error in node red cast node “Not able to load media:Load failed Not able to load the media.”

Google TTS is now working again. I am not sure what changed.

I have the same error:

“Failed to cast media https://myDuckDnsUrl.duckdns.org:8123/media/castle-doorbell-chime.mp3 from internal_url (https://myDuckDnsUrl.duckdns.org:8123) Please make sure the URL is: Reachable from the cast device and either a publicly resolvable hostname or an IP address”

I’ve setup duck DNS and can successfully use HomeAssistant with

https://myDuckDnsUrl.duckdns.org:8123/

In my config.yml I have also added

homeassistant:
    allowlist_external_dirs:
        - "/media/"
    allowlist_external_urls:
        - "https://myDuckDnsUrl.duckdns.org:8123"

(btw if I try to add /local/ to dirs I get an error Not a directory @ data['allowlist_external_dirs'][1])

For the Action In my automation file as ContentID I’ve tried both with and without /local/ in
https://myDuckDnsUrl.duckdns.org:8123/local/media/castle-doorbell-chime.mp3

Although I’m not sure if that is the actual ContentID/filelocation, because if I check via my macbook connected via samba it shows as filepaht:
/Volumes/media/castle-doorbell-chime.mp3

If I try to open song directly in my browser using any of the urls below I also get a 404

https://myDuckDnsUrl.duckdns.org:8123/local/media/castle-doorbell-chime.mp3
https://myDuckDnsUrl.duckdns.org:8123/Volumes/media/castle-doorbell-chime.mp3
https://myDuckDnsUrl.duckdns.org:8123//media/castle-doorbell-chime.mp3

But from my dashboard in lovelace I can play the song in my media-browser.
https://myDuckDnsUrl.duckdns.org:8123/media-browser

Also in my https://myDuckDnsUrl.duckdns.org:8123/config/core I have set internal and externaal url to my duckDns url:
https://myDuckDnsUrl.duckdns.org:8123

Any ideas?

I don’t know if it has anything to do with your issue but I notice I have https://homeassistant.local:8123/ as my Internal url on General configuration (duckdns url for External url though)

I’m having the same problem. Am trying media_player.play_media from the Dev console, trying to cast to my Google Home Mini:

Failed to cast media https://myddns.ddns.net:8123/media/countdown.mp3 from tts.base_url (https://myddns.net). Please make sure the URL is: Reachable from the cast device and either a publicly resolvable hostname or an IP address

I have base_url set as follows:

tts:
  - platform: google_translate
    base_url: https://myddns.ddns.net
    service_name: google_say

If I use an http URL on another server it works fine - e.g:

http://mydomain.com/countdown.mp3

I have tried to set my internal url to https and http://homeassistant.local/ and changed also the contentId path in my automation script to
https - and http://homeassistant.local:8123/media/castle-doorbell-chime.mp3

I get the same error:

[homeassistant.components.cast.media_player] Failed to cast media https://homeassistant.local:8123/media/castle-doorbell-chime.mp3 from internal_url (https://homeassistant.local:8123). Please make sure the URL is: Reachable from the cast device and either a publicly resolvable hostname or an IP address

Something strange has come up, when I used my local ip with http, the stop command showed an error revealing the path of my mp3 file: http://192.168.172.56:8123/media/local/castle-doorbell-chime.mp3
notice that it says /media/local/ instead of just /media/ or /local/media/ (what I tried before).
I then tried to add that path to my allowlist_external_dirs: but that failed, so I reverted it to just /media/

When I tried the /media/local/ this with my dns url https://myDuckDnsUrl.duckdns.org:8123/media/local/castle-doorbell-chime.mp3
The error slightly changed to

2021-08-07 21:40:20 ERROR (Thread-7) [homeassistant.components.cast.media_player] Failed to cast media https://myDuckDnsUrl.duckdns.org:8123/media/local/castle-doorbell-chime.mp3?authSig=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmOWJhZTVhMWRhMGI0ZDMxOTE3YTA4MmFkMjc0NWQzOSIsInBhdGgiOiIvbWVkaWEvbG9jYWwvY2FzdGxlLWRvb3JiZWxsLWNoaW1lLm1wMyIsImlhdCI6MTYyODM2NTIyMCwiZXhwIjoxNjI4NDUxNjIwfQ.6DpuQ5zA8BYHJgMussx_XDFcEqYG-nTS3w3h8ociroc from external_url (https://myDuckDnsUrl.duckdns.org: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 why this authSig parameter was added 🤷

I have the feeling I’m using the wrong path, how can I see what the absolute path is of my mp3 file? I saw somewhere something about a wwww folder in the /config/ folder where my config.yml file lives 🤷

Something else strange happened, when I use my local ip address instead of my duckddns url the LivingRoom speaker card in the lovelace UI actually shows it’s playing something, yet therer is no sound. Even stranger when I then click the browse media icon on the LivingRoom speaker card and select the doorbell.mp3 I hear the sound come out of my speakers and I see the playback bar. Now when I trigger the automation script I actually see the playback bar on the LivingRoom speaker card and see the playicon change to an pause icon aas if the sound was actually plaaying but sstill no sound. Yet when I check the logs it still shows the same error:
Failed to cast media https://192.168.172.56:8123/media/castle-doorbell-chime.mp3. Please make sure the URL is: Reachable from the cast device and either a publicly resolvable hostname or an IP address

im having the same issue :frowning: any findings on this?

To access a file from /media location in home assistant. The path of the media file is appended with a authSig parameter. After some digging, I found this Authentication API | Home Assistant Developer Docs. It clearly states that to access the file ( which google home or media player requires to play it ) you need a authSig parameter / Signed Path.

Upon further googling, I stumbled upon this . it shows how another user is able to get the Signed Path in node red.
Imgur

Putting them together, I created a Node red flow which is able to play media files to Chromecasts

[{“id”:“5f6e7f2082c90387”,“type”:“tab”,“label”:“Baby”,“disabled”:false,“info”:“”},{“id”:“0ff3b5fd1e26ef6f”,“type”:“ha-api”,“z”:“5f6e7f2082c90387”,“name”:“Get AuthSign”,“server”:“76b07c6c.a5b7a4”,“debugenabled”:false,“protocol”:“websocket”,“method”:“get”,“path”:“”,“data”:“{ "type": "auth/sign_path", "path": "/media/local/private/RainNoise.webm", "expires": 300 }”,“dataType”:“jsonata”,“location”:“payload”,“locationType”:“msg”,“responseType”:“json”,“x”:550,“y”:100,“wires”:[[“eb7565c96caef9b9”]]},{“id”:“b2a406a275028308”,“type”:“server-events”,“z”:“5f6e7f2082c90387”,“name”:“zha_event_scanner”,“server”:“76b07c6c.a5b7a4”,“event_type”:“zha_event”,“exposeToHomeAssistant”:false,“haConfig”:[{“property”:“name”,“value”:“”},{“property”:“icon”,“value”:“”}],“waitForRunning”:true,“x”:150,“y”:100,“wires”:[[“4003e54dc3e0370d”]]},{“id”:“4003e54dc3e0370d”,“type”:“switch”,“z”:“5f6e7f2082c90387”,“name”:“Scene Switch”,“property”:“payload.event.device_ieee”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“60:a4:23:ff:fe:6b:75:4d”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:1,“x”:360,“y”:100,“wires”:[[“0ff3b5fd1e26ef6f”]]},{“id”:“2fe5f40cf59ba090”,“type”:“api-call-service”,“z”:“5f6e7f2082c90387”,“name”:“Play White Noise”,“server”:“76b07c6c.a5b7a4”,“version”:1,“debugenabled”:false,“service_domain”:“media_player”,“service”:“play_media”,“entityId”:“media_player.googlehome7491”,“data”:“payload.data”,“dataType”:“jsonata”,“mergecontext”:“”,“output_location”:“”,“output_location_type”:“none”,“mustacheAltTags”:false,“x”:950,“y”:100,“wires”:[]},{“id”:“eb7565c96caef9b9”,“type”:“function”,“z”:“5f6e7f2082c90387”,“name”:“Make Payload”,“func”:“varPath = "http://10.10.10.190:8123" + msg.payload.path;\nvarGoogleHome = "music";\nmsg.payload.data = {"media_content_id" : varPath, "media_content_type" : varGoogleHome, }\nreturn msg;\n”,“outputs”:1,“noerr”:0,“initialize”:“”,“finalize”:“”,“libs”:,“x”:740,“y”:100,“wires”:[[“2fe5f40cf59ba090”]]},{“id”:“76b07c6c.a5b7a4”,“type”:“server”,“name”:“Home Assistant”,“legacy”:false,“addon”:false,“rejectUnauthorizedCerts”:true,“ha_boolean”:“y|yes|true|on|home|open”,“connectionDelay”:true,“cacheJson”:true}]

Thanks @antimage, by using ‘?authSig=’ as search term and getting as first result your same link and as second the basic “Media Source Integration” where it states in its example to set the contentId for local media to:
media-source://media_source/<media_dir>/<path>

So instead of using
media_content_id: https://myDuckDnsUrl.duckdns.org:8123/media/local/castle-doorbell-chime.mp3

I used
media_content_id: media-source://media_source/local/castle-doorbell-chime.mp3

I feel so unsmart :sweat: :joy:

But also happy! Whoohoo Fixed! now I can ring my doorbell!

3 Likes

I did the same before figuring this out. The docs need updating with more examples.

1 Like

Sorry for the necro but I came across this thread when (probably due to poor reading of release notes) 2022.3 broke my local media playback functions. For anyone reading more recently who came across this thread:

  • In UI / Configurations / General I changed the Internal URL from http://homeassistant.local to the IP address of my Home Assistant EG: http://192.168.1.1:8123
  • I used the below service call, replacing media_source/media with media_source/local
service: media_player.play_media
data:
  media_content_id: media-source://media_source/local/doorbell.mp3
  media_content_type: media/mp3
target:
  entity_id: media_player.living_room_speaker
2 Likes

Thankyou, this helped me :blush:

1 Like

Thank you so much! Recently I had intermittent issues playing media on my Homepad Mini. Your instructions helped me fix the problem.