I'm testing my chromecast with pjjanak's chromecast-hello-world
app located on github here.
He adds a listener to the message
event, which is effectively checking that the content API is getting injected.
window.addEventListener('message', function(event) {
if (event.source === window && event.data &&
event.data.source === 'CastApi' &&
event.data.event === 'Hello') {
console.log('message event');
initializeApi();
}
});
message event
is getting correctly logged to the console, so I'm sure the chrome app whitelisting is set up correctly.
I also have the following:
initializeApi = function() {
if (!cast_api) {
cast_api = new cast.Api();
cast_api.addReceiverListener('my_app_id_is_here', onReceiverList);
console.log('initializeApi');
}
};
onReceiverList = function(list) {
console.log('receiverlist:' + list);
//snipped other stuff from here...
}
The problem is, that the addReceiverListener is being called, but the receiver list is always empty. The console just logs: receiverlist:
My Chomecast appears to be in developer mode, as I can access the developer tools through port 9222. However, I didn't have the "Send this Chromecast's serial number when checking for updates" box ticked previously (I've ticked it now, and performed a few reboots/resets to no avail).
I'm quite stumped. Any ideas?