lbry-desktop/ui/component/viewers/videoViewer/internal/chromecast.js
2021-12-10 14:16:03 -05:00

24 lines
743 B
JavaScript

// @flow
/**
* Wrapper for @silvermine/videojs-chromecast
*/
export default class Chromecast {
/**
* Actions that need to happen after initializing 'videojs'
*/
static initialize(player: any) {
// --- Start plugin ---
player.chromecast();
// --- Init cast framework ---
const CHROMECAST_API_SCRIPT_ID = 'chromecastApi';
const existingChromecastScript = document.getElementById(CHROMECAST_API_SCRIPT_ID);
if (!existingChromecastScript) {
const script = document.createElement('script');
script.src = 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1';
script.id = CHROMECAST_API_SCRIPT_ID;
// $FlowFixMe
document.body.appendChild(script);
}
}
}