Reputation: 126
So a couple of month back I wrote a test sender to get some experience with Cast senders. It worked fine and I could send images and videos to my Chromecasts.
I now need to create a custom receiver and I wanted to use my old sender to test my receiver code. However, my sender doesn't work anymore eventhough I didn't change anything since then.
The errors i'm now getting in Chrome's console are the following:
GET file://www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js net::ERR_FILE_NOT_FOUND
Uncaught ReferenceError: cast is not defined
at window.__onGCastApiAvailable (script.js:84)
at chrome.cast.cb (cast_sender.js:99)
When I look at the "Network" tab I can see that the cast_framework.js file failed to load after 22s.
I then tried to use the sample on Google's Github to see if it was my sender that was at fault but I get the same error.
I also can reach the devices with the Cast button in Chrome's menu.
What is going on with that file? Is it my browser that has a problem? Is it my devices?
Upvotes: 0
Views: 5153
Reputation: 126
So the problem was the following:
As you can see the browser was looking for the file with file://
. This happens because I launched my HTML file locally so the url in the browser was file:///home/.../index.html
and I guess when it loads the framework file it guesses that it has to use file://
too instead of html://
.
Someone told me that I should serve the file from a server so I made a brief Node server with express.static to serve the file and it then worked again when I loaded the page via localhost:4000
.
I still don't know how it worked a couple of month ago but I guess I was just lucky in some way.
Upvotes: 3
Reputation: 322
Upon checking, this file below is visible:
www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js
You might want to try putting these codes inside your head tag in your html file that calls "script.js":
Check this Github Guide
Include the cast_sender.js tag
Add the script tag to your HTML page
<script type="text/javascript" src="www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js"></script>
<script type="text/javascript" src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script>
Upvotes: 2