Casting audio to google mini

I have been trying to set up a way to cast my weather. Everything works until I try to play any audio to a google mini. If I cast an audio from my web server, it all works, but nothing from the pi device, itself. I get the following in the debug panel:

Not able to load media:Load failed Not able to load the media.

Any help would be appreciated.

[{"id":"43091b5c.d97da4","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"a17b9ea9.6a949","type":"cast-to-client","z":"43091b5c.d97da4","name":"","url":"","contentType":"","message":"","language":"en","ip":"10.10.7.20","port":"8009","volume":"50","x":800,"y":140,"wires":[[]]},{"id":"24563bf6.d167e4","type":"inject","z":"43091b5c.d97da4","name":"Play","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":250,"y":140,"wires":[["3f5f4775.a5e218"]]},{"id":"3f5f4775.a5e218","type":"trigger","z":"43091b5c.d97da4","name":"tts + reset volume","op1":"{\"url\":\"http://10.10.7.6/home/mike/web/pi/tmp/wavenet_test.mp3\",\"contentType\":\"audio/mp3\",\"volume\":70}","op2":"{\"volume\":50}","op1type":"json","op2type":"json","duration":"7","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":540,"y":140,"wires":[["a17b9ea9.6a949"]]}]

I see you are sending http://10.10.7.6/home/mike/web/pi/tmp/wavenet_test.mp3 to the device.

Can you verify this file is available at that URL by putting the URL in a browser?

Also, is this IP accessible to the cast device?

A good test would be to click this >> http://10.10.7.6/home/mike/web/pi/tmp/wavenet_test.mp3 << on your phone or a tablet on the same SSID as the google cast device to verify is URL is accessible across your wifi.

You can also test the rest of the flow by replacing "url":"http://10.10.7.6/home/mike/web/pi/tmp/wavenet_test.mp3

with

"url": "http://www.orangefreesounds.com/wp-content/uploads/2018/11/Ding-dong-doorbell-rings.mp3",

and see if it works

10.10.7.6 is the pi that node-red is also on. I changed the permissions to 777 on the mp3 file just in case. My webserver is not local, but on a hosted machine. I tried the url above for the doorbells, and they work. The 10.10.7.6 from the statement above doe not. I have tried to place the mp3 file in different locations, from root /tmp , /data , home/pi/tmp , and others.
When I try to use a browser to get to http://10.10.7.6/home/mike/web/pi/tmp/wavenet_test.mp3 , it shows not found. It's funny I can write an mp3 file to the system, but cannot read it

Do you have a web server running on port 80 hosting the file?

You do know you cannot just access via http without a web server right?

You can however, present the file via a http endpoint in node-red.

try this

Wellll, Something I never thought of. Time to remove the apache2 server. Thanks for all the help

1 Like

Its really amazing what you can achieve with just node-red :slight_smile:

You can also place the files in the http static folder of node-red, and the url would be http://ip_of_node-red:1880/wavenet_test.mp3

I assume that would only work if you have left your http endpoints unsecured.

And there-in lies the problem. I uninstalled apache2, but it still does not allow for reading of the file. I can be saved, just not read. I think I'll reinstall the OS on the Pi and start again.

what does that mean?

you dont need apache - did you try the solution I linked to?

I have tried all the solution provided. I cannot list an file under the 10.10.7.6:1880, or any folder in the .node-red folder.
I did something to foul this up. I added Peter Scargills' script a while back, and am starting to wonder if some setting, somewhere, has changed. I checked the settings.js, and all the settings are at default.

ok, follow this...

  1. copy your mp3 to ~/.node-red folder & name it bell.mp3
  2. paste the below flow into node-red (ctrl+i)...
    image
[{"id":"d5a6dd33.a0e28","type":"http in","z":"553814a2.1248ec","name":"","url":"/bell","method":"get","upload":false,"swaggerDoc":"","x":260,"y":1200,"wires":[["d59c8c4.b480d7","e7ed07e7.97da58"]]},{"id":"d59c8c4.b480d7","type":"file in","z":"553814a2.1248ec","name":"","filename":"bell.mp3","format":"","chunk":false,"sendError":false,"encoding":"none","x":500,"y":1200,"wires":[["87b9c5b8.526558","49056e53.5a32b"]]},{"id":"87b9c5b8.526558","type":"http response","z":"553814a2.1248ec","name":"","statusCode":"","headers":{"contentType":"audio/mp3"},"x":730,"y":1200,"wires":[]},{"id":"e7ed07e7.97da58","type":"debug","z":"553814a2.1248ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":370,"y":1240,"wires":[]},{"id":"49056e53.5a32b","type":"debug","z":"553814a2.1248ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":1240,"wires":[]},{"id":"b72151a6.617e3","type":"cast-to-client","z":"553814a2.1248ec","name":"","url":"","contentType":"","message":"","language":"en","ip":"","port":"","volume":"","x":730,"y":1300,"wires":[[]]},{"id":"2dbcc2cc.94f80e","type":"inject","z":"553814a2.1248ec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"ip\":\"10.10.7.20\",\"url\":\"http://10.10.7.6:1880/bell\",\"contentType\":\"audio/mp3\",\"volume\":50}","payloadType":"json","x":250,"y":1300,"wires":[["b72151a6.617e3"]]}]
  1. Double click the INJECT node & set ip / url accordingly...
    e.g..
{
    "ip": "10.10.7.20",
    "url": "http://10.10.7.6:1880/bell",
    "contentType": "audio/mp3",
    "volume": 50
}

ip - this should be the ip of the google device
url - this should be ip of your PI

if you follow the above correctly, you should get the mp3 by clicking this >> http://10.10.7.6:1880/bell <<

Same error:
Error: ENOENT: no such file or directory, open 'bell.mp3'

You must not have the file in the right place.

Can you list your directory...

cd ~/.node-red
ls


changed settings.js to force userDir: /home/mike/.node-red just in case

You must not have the file in the right place

I re-built the pi, with only node-red and a web server. With the mp3 files under /var/www/html/ directory, I can access those audio files

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.