0

I'm sorry if it is a silly question but I really can't figure out how to send local file to chromecast default media receiver.

var url = "http://localhost:3000/myvideo.mp4"
var mediaInfo = new chrome.cast.media.MediaInfo(url, 'video/mp4');

I tried using "http://localhost/myvideo.mp4", "http://localhost:3000/myvideo.mp4", "http://127.0.0.1/myvideo.mp4", "http://127.0.0.1:3000/myvideo.mp4" but nothing happens. The file it's in the server but it always fail to load. It's something so simples but I can't figure out. I'm going nuts!

  • `localhost` is always relative to the device attempting to initiate the connection. When the Chromecast connects to the URL `http://localhost:3000/myvideo.mp4`, where do you think that request goes? – MTCoster Oct 14 '18 at 20:25
  • I believe the directory of my local server. I'm running a simples node server. In my directory I have a myvideo.mp4 file and an index.html where I'm trying to cast the video. – Mateus Rodrigues Oct 14 '18 at 21:17
  • Take a look at [this question & answer](https://stackoverflow.com/q/5524116/1813169) - I think you're missing the point of `localhost`. – MTCoster Oct 14 '18 at 22:34
  • If I enter `http://localhost:3000/myvideo.mp4` on the browser the video plays normally, but when I pass it to `chrome.cast.media.MediaInfo` it always fail – Mateus Rodrigues Oct 15 '18 at 04:35
  • You said that in your question. Did you understand the page I linked? – MTCoster Oct 15 '18 at 07:48
  • Yes. I had already exposed the server to local LAN. The problem was the server was missing **CORS authorization**. It's working now. Thank you for the help! – Mateus Rodrigues Oct 15 '18 at 12:00

1 Answers1

0

The best way to debug issues like this is to use the Chrome Remote Debugger: https://developers.google.com/cast/docs/debugging

This will only work if you have a custom receiver.

You will likely see an error in the Javascript console.

Leon Nicholls
  • 4,623
  • 2
  • 16
  • 17