0

I am trying to get Google Cast to work with Apache Cordova but I am having a hard time getting it working. Most guides and plugins are out of date and have not been updated in awhile. I found a plugin that was updated 3 months ago but I keep getting this error:

Uncaught ReferenceError: chrome is not defined
at CastPlayer.initializeCastPlayer (CastVideos.js:138)
at new CastPlayer (CastVideos.js:118)
at index.js:57
at HTMLScriptElement.script.onload (index.js:74)

cordova.js and index.js are both defined in my HTML file but index.js still cannot find the google cast plugin.

This is the repo for the plugin I have been trying to use

https://github.com/nbabanov/cordova-chromecast

And this is the sample project I was trying because I have been unsuccessful at getting the plugin to work while writing my own projects.

https://github.com/Vaporexpress/Cordova-CastVideos-chrome

I am using Cordova android 6.3.0 & and the target SDK version for my project is 26. I have node.js 8.8.1 installed as well. I have been testing the app on my S7 Edge running Android 7.0

Any help would be appreciated.

2 Answers2

0

This kind of Uncaught ReferenceError: chrome is not defined has to do with the Chrome version. You may refer here.

You may also check the sample plugins in this thread.

There are a few plugins available, try them

https://github.com/GetVideostream/cordova-chromecast // Android

https://github.com/AVGP/cordova-chromecast // Android

https://github.com/SesamTV/ChromecastCordova // Android

https://github.com/rbackhouse/chromecast_cordova_plugin // Android

https://github.com/noppolp/wondex-chromecast-cordova // iOS

abielita
  • 13,147
  • 2
  • 17
  • 59
0

Perhaps a bit late to the party, but here's my two cents: I had the same issue, but that was because I didn't put the code in the onDeviceReady().

After I did this (or in my case: put it in a seperate function that I called), it worked.

SibrenB
  • 71
  • 3