I can't seem to find this problem anywhere else and I'm getting frustrated with it. Basically, I have whitelisted my device successfully and I am starting to develop a simple 'Hello World' application using Chrome as my sender. I went in and I whitelisted localhost
in the Chromecast extension and added data-cast-api-enabled="true"
to the html tag of my sender page. It even seems as if the extension is trying to inject the API.
But, in the Chrome debugger I get an error: Uncaught SyntaxError: Unexpected token ILLEGAL
I looked in the network tab and saw that api_script.js
was coming in from the extension and I could even open it in a separate tab. But, for some reason this page is interpreting this javascript file as...well, what appears to be Japanese. In the network tab, the response for the request for api_script.js
is (and this is just abbreviated):
....慶慣瑳㴠挠獡⁴籼笠㭽挊獡䅎䕍㴠∠慃瑳灁≩慣瑳嘮剅䥓乏㴠嬠ⰲ㐠㭝挊獡敒散癩牥㴠映湵瑣潩⡮摩慮敭 桴獩椮‽摩†桴獩渮浡‽慮敭†桴獩椮味扡牐橯捥整‽桴獩椮䅰摤敲獳㴠渠汵੬㭽挊獡慌湵档敄捳楲瑰潩‽畦据 湯⤨笠 琠楨牵‽桴獩琮硥⁴‽畮汬紊慣瑳䰮畡据剨煥敵瑳㴠映湵瑣潩⡮捡楴楶祴祔数敲散癩牥 †桴獩愮瑣癩瑩呹灹 ‽捡楴楶祴祔数†桴獩爮捥楥敶‽敲散癩牥†桴獩搮獥牣灩楴湯㴠琠楨慰慲敭整獲㴠渠汵㭬 琠楨楤捳湯敮瑣潐楬 㴠∠潣瑮湩敵ਢ...
I'm not really sure why this is happening. It seems like copying the API code directly into my webpage is the only way I can get this thing working at all. Does anyone have any insight on this?
Chromecast is interpreting your script as UTF-16 (as proof, I pasted that garbage and saved it as UTF-16-LE, and got a text file starting with var cast = cast || {};
).
Make sure you don't have a BOM header on the script. If the problem is due to charset detection, try adding some extended-ASCII characters in a comment near the beginning to force charset detection to pick e.g. UTF-8.