Reputation: 21
I'm struggling to understand the initial set up of my chromecast for casting on a local network. I want to test a media server app which I am developing in my spare time. The backend is an indexing server and I want the ability to cast media from my browser to the television.
I applied for and paid for access to the developer console which allowed me to register the serial number of the chromecast device. However the next step seems to be asking me to register a URL and publish the application.
This application is sandboxed and will be running on a local network though so I don't understand this step. When I try to run the sample applications on github I run into problems when I attempt to pass links into local media files (of any format) on my server.
These errors have included 'Cast API not present' or whitescreening of the browser. Would anyone who has successfully set up the API on their local network for casting explain how to do this initial configuration. Specifically, if you are running on a local (192.168.x.x) network (is https necessary?) and running a server (Tomcat in this case) on one of those machines which URLs do you provide for the custom receiver and (I guess) the sender.
Thanks a mill...
J
Upvotes: 0
Views: 7368
Reputation: 16308
It was confusing for me as well. But I finally found out that you need to host the receiver locally, and then expose that using a tool/service like ngrok. This is explained in step 3 in this tutorial:
https://codelabs.developers.google.com/codelabs/cast-receiver/index.html?index=..%2F..index#2
The gist is something like this, it can likely be done in other ways using other tools but this is according to the tutorial:
npm install -g http-server
npm install -g ngrok
cd app-done // This is the directory on your machine with the receiver app (like index.html etc)
http-server
After starting the http server above, make note of the port used. It might be 8080.
Use that port in the call to ngrok.
ngrok http 8080
Remember to leave http-server AND ngrok running. Ngrok will give you a publicly available URL, that URL will actually access your local http server, pointing to your receiver.
(Side note, and this is still bugging me (feel free to leave a comment if you know the answer): even though we can use a local receiver in this way, any URLs we throw to this receiver are still always worldwide URLs, i.e. we can never use local media from domains whose IPs are replaced by local IPs in hosts files etc. So we always have to use production (publicly available) media. I'd really like to find a way around this. However we can use IP number addresses in the local range, like 10.101.xxx.yyy etc)
Upvotes: 0
Reputation: 892
You need to registered your device so your Chromecast device can access the receiver app with or without SSL whether local or on the Internet. (HTTP and HTTPS)
A receiver app is a HTML file (receiver.html or whatever name you chose) and you registered its URL (http://192.168.x.x/whatever.html) when you generate an AppID using Google developer console.
With AppID in step 2 above, you put it in your native app (iOS, etc.)
Your native app then using Google API to search, connect, and do some handshaking with the connected cast device.
Because of the AppID, the connected cast device knows where/what URL to get the receiver app (http://192.168.x.x/whatever.html)
The rest is up to you what you are doing with your native app.
If you want to host media resources on your local network, you would need a web server, etc. That is the role of your sender app (native app) to communication with the connected cast device and send it the URLs for any resources.
One final note: Your cast device got the list of AppIDs and their corresponding receiver app URLs from Google.
Hope this help.
Edit: Resources URLs needed not be SSL.
Upvotes: 1