Closed JudeOsborn closed 10 years ago
I was able to get chromecast to initialize and play a media file!. Your code is good the only two things that could be an issue is the appID or your sessionListener.
var glb_session;
initializeCastApi = function() { var applicationID = 'CC1AD845'; //change to your own var sessionRequest = new chrome.cast.SessionRequest(applicationID); var apiConfig = new chrome.cast.ApiConfig(sessionRequest, sessionListener, receiverListener);
chrome.cast.initialize(apiConfig, onSuccess, onFail); }
function sessionListener(e) { glb_session = e; }
function receiverListener(e) { if(e === chrome.cast.ReceiverAvailability.AVAILABLE) { //alert('good ReceiverAvailability'); } else { //alert('bad ReceiverAvailability'+e); } }
My appID is published and I have included the meta-data tag in the AndriodManifest. I hope this helps!
Marques
Okay, I'll see about using my own app. The appid In my code is supposed to be the default id that every Chromecast has, so I would have expected it to work, but maybe it doesn't for some reason.
Looks like the problem was that the libraries were not installed correctly. I wasn't getting any errors, but nothing at all was happening. I fixed up the local.properties files and it seems things are working better. I can now initialize the chromecast. Yay! The problem I'm having now is when I do a requestSession() and tap on my chromecast in the pop up menu I get the error "java.lang.NoSuchMethodError: com.google.android.gms.common.api.GoogleApiClient$Builder.addApi"
Any idea what might be causing this? I only found one Google result that seems to be related to gradle, but doesn't appear to help me any. Once I get this working I'm literally going to pop a champagne bottle. I've been mired in a world of Java dependencies for way too long.
Never mind. Looks like I just needed to update to the latest version of the plugin. No more error now.
And holy crap, it finally worked!
Awesome!
Are you guys running on emulator or the real devices?
Would you happen to have a code example where chromecast is working? When I try chrome.cast.initialize() I get the error callback with "api_not_initialized". I've followed the initialization code in tests.js (which is basically the Chrome API). For example, I tried putting this in the bindEvents function:
This results in "initialize error' in the console when touching the app. I do have a working Chromecast running on the same network as the phone to which the cordova app is deployed, and the phone can connect using other apps like YouTube, but not a deployed cordova app with this extension. Maybe I'm integrating it wrong somehow. A working code example would be awesome.