From a287cf92c958cb2424e8b84f4ef14870a1b938cd Mon Sep 17 00:00:00 2001 From: Jonathan Jogenfors Date: Tue, 12 Nov 2024 00:07:25 +0100 Subject: [PATCH] wip --- .../lib/components/cast/cast-button.svelte | 12 +++++++--- web/src/lib/utils/cast-player.ts | 23 ++++++------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/web/src/lib/components/cast/cast-button.svelte b/web/src/lib/components/cast/cast-button.svelte index 87df177e1acfd..2515828220c2f 100644 --- a/web/src/lib/components/cast/cast-button.svelte +++ b/web/src/lib/components/cast/cast-button.svelte @@ -3,10 +3,16 @@ import Button from '$lib/components/elements/buttons/button.svelte'; import { onMount } from 'svelte'; - onMount(async () => { - await loadCastFramework(); - CastPlayer.getInstance(); + onMount(() => { + loadCastFramework(); }); + + window['__onGCastApiAvailable'] = function (isAvailable) { + // The cast sender can't be initialized until the API is available + if (isAvailable) { + CastPlayer.getInstance(); + } + };