nbabanov/cordova-chromecast

help with initialization

Closed this issue · 3 comments

Hi,
Im trying to connect chromecast to my android ionic hybrid app.

on a browser that code works ... :

<script type="text/javascript"> window['__onGCastApiAvailable'] = function(isAvailable) { if (isAvailable) { var options = {}; options.receiverApplicationId = '06CCA653'; options.autoJoinPolicy = chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED; cast.framework.CastContext.getInstance().setOptions(options); } }; </script>

My first problem was that isAvailable was always false, but after installing your plugin, it became true.
So, your plugin is well installed.

The question is if can I do something like that code, because that : " cast.framework.CastContext.getInstance().setOptions(options); " gives me an error Uncaught ReferenceError: cast is not defined

I am using that cordova plugin on Ionic.

With your example code, My chromecast is not beeing connected, the console:

initialize tab_and_origin_scoped 06CCA653
index.html:124 onInitSuccess
index.html:125 undefined
index.html:119 receiverListener
index.html:120 unavailable

Thanks.

I think you forgot that the cast object is a property of the chrome object.

Try with: chrome.cast.framework.CastContext.getInstance().setOptions(options);

It doesnt work.

I dont know which is my error. In browser, it works; but not in my ionic project. The icon of cast doesnt appear. Could you provide me an example connection code to test it inside my ionic project ?

I fix it.
Thks.