Minor cast.framework changes

This commit is contained in:
hensm
2019-03-19 18:35:25 +00:00
parent 270d661de0
commit 894738889a
3 changed files with 17 additions and 10 deletions

View File

@@ -25,7 +25,7 @@ type EventHandler = (eventData:
type MessageListener = (namespace: string, message: string) => void;
export default class RemotePlayer {
export default class CastSession {
constructor (sessionObj: Session, state: string) {
console.info("STUB :: CastSession#constructor");
}

View File

@@ -44,16 +44,22 @@ export default {
, RemotePlayer, RemotePlayerChangedEvent, RemotePlayerController
, SessionStateEventData, VolumeEventData
, CastContext: Object.assign(CastContext, {
getInstance () {
/**
* CastContext class with an extra getInstance method used to
* instantiate and fetch a singleton instance.
*/
, CastContext: {
...CastContext
, getInstance () {
if (castContext) {
return castContext;
return castContext
}
castContext = new CastContext();
return castContext;
}
})
}
, VERSION: "1.0.07"

View File

@@ -7,13 +7,14 @@ import { onMessage } from "./messageBridge";
const global = (window as any);
if (!global.chrome) {
global.chrome = {};
}
global.chrome = {};
global.chrome.cast = cast;
/**
* If loaded within a page via a <script> element,
* document.currentScript should exist and we can check its
* [src] query string for the loadCastFramework param.
*/
if (document.currentScript) {
const currentScript = (document.currentScript as HTMLScriptElement);
const currentScriptUrl = new URL(currentScript.src);