diff --git a/dashboard-ui/scripts/chromecast.js b/dashboard-ui/scripts/chromecast.js index 04e81a81a5..2374731633 100644 --- a/dashboard-ui/scripts/chromecast.js +++ b/dashboard-ui/scripts/chromecast.js @@ -1,4 +1,4 @@ -(function (window, chrome, console) { +define(['https://www.gstatic.com/cv/js/sender/v1/cast_sender.js'], function () { // Based on https://github.com/googlecast/CastVideos-chrome/blob/master/CastVideos.js var currentResolve; @@ -90,6 +90,8 @@ */ CastPlayer.prototype.initializeCastPlayer = function () { + var chrome = window.chrome; + if (!chrome) { return; } @@ -861,9 +863,17 @@ castPlayer = new CastPlayer(); - MediaController.registerPlayer(new chromecastPlayer()); + var registeredPlayer = new chromecastPlayer(); + MediaController.registerPlayer(registeredPlayer); + + // To allow the native android app to override + document.dispatchEvent(new CustomEvent("chromecastloaded", { + detail: { + player: registeredPlayer + } + })); } - requirejs(["https://www.gstatic.com/cv/js/sender/v1/cast_sender.js"], initializeChromecast); + initializeChromecast(); -})(window, window.chrome, console); \ No newline at end of file +}); \ No newline at end of file diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index f919c61b7c..6a3d21641c 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -2276,16 +2276,18 @@ var AppInfo = {}; if (Dashboard.isRunningInCordova()) { - postInitDependencies.push('cordova/connectsdk'); - if (browserInfo.android) { postInitDependencies.push('cordova/android/mediasession'); + postInitDependencies.push('cordova/android/chromecast'); + } else { postInitDependencies.push('cordova/volume'); } if (browserInfo.safari) { + postInitDependencies.push('cordova/connectsdk/connectsdk'); + postInitDependencies.push('cordova/ios/orientation'); if (Dashboard.capabilities().SupportsSync) {