How to cast videos

HI ,

Is there a way to cast local / youtube videos in a node red flow ?

Thanks !

did you try the search option in this forum to look for cast ?
or for any flows and nodes ?

Thanks for the response .I tried using "node-red-contrib-cast" . There is a sample flow in the documentation to play local files. When I import it , I"m missing a node .Not sure what that that is .

Here is a screenshot from example

Here is the screenshot when I import it

I'm guessing that is an amazon dash button... in which case it's just sending any msg you like in to trigger the next nodes - so just try replacing it with an inject sending a 1 or a "" string.

I tried that and now I get this error . The flow is unable to load the media file .

Appreciate any help .

Thanks !

You simply don't understand what's happening.

You should probably spend some time reading up on node red. Perhaps watch some videos.

Chromecast only plays media from a URL

The top line of this flow creates a URL

That URL serves a file (the brown node named "doorbell.mp3")

Do you have a file called doorbell.mp3 ?

Have you tested the endpoint (URL) http://localhost:1880/endpoint/alavp

Have you checked the cast node settings?

Perhaps the dash button was sending the URL to the cast node - you might need to mimic that.

Sorry, I should have provided more details . The endpoint is not reachable . Error : Cannot get /alavp

The files exist and the cast configs are correct .

Put a debug node after the get and a 2nd debug node after the brown file node.

The 1st debug node will let you know if you anything is hitting the endpoint. The 2nd debug will tell you if the file is being found and loaded.

Looks like nothing is hitting the end point .

When I click the inject , I can see that it can pass the signal to my cast device . But as the end point is not reachable ,it's unable to load the media .

What is the config of the cast node. Post a screen shot.

My guess is...

Don't send localhost to the Chromecast. It won't know where localhost is.

I tried installing the dash button but the installation is failing . My node red is running on home assistant instance .The trigger node will send the message to the cast node . The cast node settings are empty.Note that I replaced my IP with XX for the screen shot purpose

--Screenshot of trigger node

The below are being sent from trigger node . The ip here is the IP address of my cast device

    "ip": "192.168.XX.XX",
    "url": "http://192.168.XX.XX:1880/alavp",
    "contentType": "audio/mp3",
    "volume": 50

screenshot of cast node

The HTTP In node in your screenshot is configured with the path /endpoint/alavp. The URL you are passing in doesn't have the /endpoint part.

Remember you can test the URL directly in your browser without sending it to the cast node.

Thanks for the response .I tried adding the /endpoint part in the URL and tested in browser but still can't get it .The debug from file node shows below message

"Error: ENOENT: no such file or directory, open '/tmp/alavp.mp3'"

The file physically exists in the /tmp directory. Am I missing any configs. here ?

Well if the File node says it can't find the file, then it can't find the file.

Just to double check, you have the file in /tmp/alavp.mp3 on the machine running Node-RED and not the device you are using to access the editor (in case they are different).

Yes the file exists on the server where nod-red is running

Then potentially the account that runs node-red doesn't have access to that file. Try checking & if necessary adjusting the MP3 files permissions

Yeah I changed he permissions but no avail . I am checking from the home-assistant side now .May be there could be some configs on that I missed .

Since you are running Home Assistant, you might want to look into I did it, I defeated the horrible Google Home cast start prompt sound. I have not found a way to not get the annoying sound with any of the cast nodes in NR.

I'm not certain what home-assistant has to do with this?

I cant imagine what setting up a URL to host an MP3 has to do with anything outside of node-red.

The first test in my mind is - can you access the MP3 in your browser? If you cant, then there is no way the cast device is gonna.

On the same machine where node-red is running, what happens if you point your browser at http://localhost:1880/endpoint/alavp ?
do you get anything?

PS - it works for me...

[{"id":"d5a6dd33.a0e28","type":"http in","z":"c70ba4a4.e7fb58","name":"","url":"/endpoint/alavp","method":"get","upload":false,"swaggerDoc":"","x":110,"y":120,"wires":[["d59c8c4.b480d7","e7ed07e7.97da58"]]},{"id":"d59c8c4.b480d7","type":"file in","z":"c70ba4a4.e7fb58","name":"","filename":"alavp.mp3","format":"","chunk":false,"sendError":false,"encoding":"none","x":180,"y":160,"wires":[["87b9c5b8.526558","49056e53.5a32b"]]},{"id":"87b9c5b8.526558","type":"http response","z":"c70ba4a4.e7fb58","name":"","statusCode":"","headers":{"contentType":"audio/mp3"},"x":360,"y":160,"wires":[]},{"id":"e7ed07e7.97da58","type":"debug","z":"c70ba4a4.e7fb58","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":320,"y":80,"wires":[]},{"id":"49056e53.5a32b","type":"debug","z":"c70ba4a4.e7fb58","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":340,"y":120,"wires":[]},{"id":"b72151a6.617e3","type":"cast-to-client","z":"c70ba4a4.e7fb58","name":"","url":null,"contentType":"","message":null,"language":"en","ip":"","port":"","volume":null,"x":360,"y":220,"wires":[[]]},{"id":"2dbcc2cc.94f80e","type":"inject","z":"c70ba4a4.e7fb58","name":"","topic":"","payload":"{\"ip\":\"\",\"url\":\"\",\"contentType\":\"audio/mp3\",\"volume\":50}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":80,"y":220,"wires":[["b72151a6.617e3"]]}]


  • put an MP3 called alavp.mp3 in the .node-red folder (or adjust the path of the file in node)
  • change the 2 IP addresses in the inject node
    • change "ip" to your cast device IP
    • change "url" to your node-red PC IP
1 Like

I have used /share in home assistant to save the mp3 file and that worked . Node red cannot read files from /tmp in home assistant . I appreciate your response and thanks for your time .