castable-video
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -8,3 +8,2 @@ /* global chrome, cast */ | ||
onCastApiAvailable, | ||
isChromeCastAvailable, | ||
castContext, | ||
@@ -23,4 +22,10 @@ currentSession, | ||
onCastApiAvailable((isAvailable) => { | ||
if (isAvailable && !cf) { | ||
onCastApiAvailable(() => { | ||
if (!globalThis.chrome?.cast?.isAvailable) { | ||
// Useful to see in verbose logs if this shows undefined or false. | ||
console.debug('chrome.cast.isAvailable', globalThis.chrome?.cast?.isAvailable); | ||
return; | ||
} | ||
if (!cf) { | ||
cf = cast.framework; | ||
@@ -114,3 +119,3 @@ | ||
if (!isChromeCastAvailable()) { | ||
if (!globalThis.chrome?.cast?.isAvailable) { | ||
throw new NotSupportedError('The RemotePlayback API is disabled on this platform.'); | ||
@@ -117,0 +122,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/* global chrome, cast, WeakRef */ | ||
/* global WeakRef */ | ||
@@ -24,3 +24,3 @@ export const privateProps = new WeakMap(); | ||
export function onCastApiAvailable(callback) { | ||
if (!isChromeCastAvailable()) { | ||
if (!globalThis.chrome?.cast?.isAvailable) { | ||
globalThis.__onGCastApiAvailable = () => { | ||
@@ -33,10 +33,10 @@ // The globalThis.__onGCastApiAvailable callback alone is not reliable for | ||
.whenDefined('google-cast-button') | ||
.then(() => callback(chrome.cast.isAvailable)); | ||
.then(callback); | ||
}; | ||
} else if (!isCastFrameworkAvailable()) { | ||
} else if (!globalThis.cast?.framework) { | ||
customElements | ||
.whenDefined('google-cast-button') | ||
.then(() => callback(chrome.cast.isAvailable)); | ||
.then(callback); | ||
} else { | ||
callback(chrome.cast.isAvailable); | ||
callback(); | ||
} | ||
@@ -52,3 +52,3 @@ } | ||
const sdkUrl = 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1'; | ||
if (globalThis.chrome.cast || document.querySelector(`script[src="${sdkUrl}"]`)) return; | ||
if (globalThis.chrome?.cast || document.querySelector(`script[src="${sdkUrl}"]`)) return; | ||
@@ -60,15 +60,4 @@ const script = document.createElement('script'); | ||
export function isChromeCastAvailable() { | ||
return typeof chrome !== 'undefined' && chrome.cast && chrome.cast.isAvailable; | ||
} | ||
export function isCastFrameworkAvailable() { | ||
return typeof cast !== 'undefined' && cast.framework; | ||
} | ||
export function castContext() { | ||
if (isCastFrameworkAvailable()) { | ||
return cast.framework.CastContext.getInstance(); | ||
} | ||
return undefined; | ||
return globalThis.cast?.framework?.CastContext.getInstance(); | ||
} | ||
@@ -75,0 +64,0 @@ |
{ | ||
"name": "castable-video", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Cast your video element to the big screen with ease!", | ||
@@ -25,3 +25,3 @@ "author": "@muxinc", | ||
"scripts": { | ||
"lint": "npx eslint@8 *.js", | ||
"lint": "eslint *.js", | ||
"serve": "wet serve" | ||
@@ -28,0 +28,0 @@ }, |
@@ -101,10 +101,10 @@ # `<castable-video>` | ||
- [Media Chrome](https://github.com/muxinc/media-chrome) Your media player's dancing suit. 🕺 | ||
- [`<youtube-video>`](https://github.com/muxinc/youtube-video-element) A custom element for the YouTube player. | ||
- [`<vimeo-video>`](https://github.com/luwes/vimeo-video-element) A custom element for the Vimeo player. | ||
- [`<wistia-video>`](https://github.com/luwes/wistia-video-element) A custom element for the Wistia player. | ||
- [`<jwplayer-video>`](https://github.com/luwes/jwplayer-video-element) A custom element for the JW player. | ||
- [`<videojs-video>`](https://github.com/luwes/videojs-video-element) A custom element for Video.js. | ||
- [`<cloudflare-video>`](https://github.com/luwes/cloudflare-video-element) A custom element for the Cloudflare player. | ||
- [`<hls-video>`](https://github.com/muxinc/hls-video-element) A web component for playing HTTP Live Streaming (HLS) videos. | ||
- [`<youtube-video>`](https://github.com/muxinc/media-elements/tree/main/packages/youtube-video-element) A custom element for the YouTube player. | ||
- [`<vimeo-video>`](https://github.com/muxinc/media-elements/tree/main/packages/vimeo-video-element) A custom element for the Vimeo player. | ||
- [`<wistia-video>`](https://github.com/muxinc/media-elements/tree/main/packages/wistia-video-element) A custom element for the Wistia player. | ||
- [`<jwplayer-video>`](https://github.com/muxinc/media-elements/tree/main/packages/jwplayer-video-element) A custom element for the JW player. | ||
- [`<videojs-video>`](https://github.com/muxinc/media-elements/tree/main/packages/videojs-video-element) A custom element for Video.js. | ||
- [`<cloudflare-video>`](https://github.com/muxinc/media-elements/tree/main/packages/cloudflare-video-element) A custom element for the Cloudflare player. | ||
- [`<hls-video>`](https://github.com/muxinc/media-elements/tree/main/packages/hls-video-element) A web component for playing HTTP Live Streaming (HLS) videos. | ||
- [`<mux-player>`](https://github.com/muxinc/elements/tree/main/packages/mux-player) The official Mux-flavored video player custom element. | ||
- [`<mux-video>`](https://github.com/muxinc/elements/tree/main/packages/mux-video) A Mux-flavored HTML5 video element w/ hls.js and Mux data builtin. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31017
667