Skip to content

Commit

Permalink
fix: no cast framework rq w/ disableremoteplayback (#72)
Browse files Browse the repository at this point in the history
fix #59
  • Loading branch information
luwes authored Dec 20, 2024
1 parent 67c7141 commit fd7a34d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/castable-video/castable-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export const CastableMediaMixin = (superclass) =>
if (this.#remote) return this.#remote;

if (requiresCastFramework()) {
loadCastFramework();
// No need to load the Cast framework if it's disabled.
if (!this.disableRemotePlayback) {
loadCastFramework();
}

privateProps.set(this, {
loadOnPrompt: () => this.#loadOnPrompt()
Expand Down
21 changes: 19 additions & 2 deletions packages/castable-video/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<script type="importmap">
{
"imports": {
"custom-media-element": "https://cdn.jsdelivr.net/npm/custom-media-element@1.0/+esm"
"custom-media-element": "https://cdn.jsdelivr.net/npm/custom-media-element@1.4/+esm"
}
}
</script>
Expand All @@ -48,6 +48,7 @@ <h1>Castable Video</h1>
>
<!-- Uses progressive enhancement for best performance -->
<video
slot="media"
poster="https://image.mux.com/O6LdRc0112FEJXH00bGsN9Q31yu5EIVHTgjTKRkKtEq1k/thumbnail.jpg?time=56"
src="https://stream.mux.com/O6LdRc0112FEJXH00bGsN9Q31yu5EIVHTgjTKRkKtEq1k/high.mp4"
crossorigin
Expand Down Expand Up @@ -82,7 +83,9 @@ <h1>Castable Video</h1>
if (castable.remote.state === 'disconnected') {
castable.remote.watchAvailability((available) => {
castBtn.hidden = !available;
castBtn2.hidden = !available;
})
.catch((error) => {
console.error(`> Error watching remote device availability: ${error}`);
})
.then((id) => {
console.log(`> Started watching remote device availability: ${id}`);
Expand All @@ -108,6 +111,20 @@ <h1>Castable Video</h1>
crossorigin
></castable-video>

<script type="module">
if (castable2.remote.state === 'disconnected') {
castable2.remote.watchAvailability((available) => {
castBtn2.hidden = !available;
})
.catch((error) => {
console.error(`> Error watching remote device availability: ${error}`);
})
.then((id) => {
console.log(`> Started watching remote device availability: ${id}`);
});
}
</script>

<br />

<div class="controls">
Expand Down

0 comments on commit fd7a34d

Please sign in to comment.