diff --git a/packages/dashboard/tailwind.config.js b/packages/dashboard/tailwind.config.js index 255314ee..3ed314b3 100644 --- a/packages/dashboard/tailwind.config.js +++ b/packages/dashboard/tailwind.config.js @@ -6,7 +6,7 @@ module.exports = { "./components/**/*.{ts,tsx}", "./app/**/*.{ts,tsx}", "./src/**/*.{ts,tsx}", - "./node_modules/@mixwave/player/**/*.{js,ts,jsx,tsx}", + "./node_modules/@mixwave/player/dist/**/*.{js,ts,jsx,tsx}", ], prefix: "", theme: { diff --git a/packages/player/lib/facade.ts b/packages/player/lib/facade.ts index 7787a1ac..83d5465e 100644 --- a/packages/player/lib/facade.ts +++ b/packages/player/lib/facade.ts @@ -37,13 +37,16 @@ export class HlsFacade extends EventEmitter { constructor(public hls: Hls) { super(); - this.intervalId_ = setInterval(() => { + const onInit = () => { + hls.off(Hls.Events.BUFFER_CREATED, onInit); + hls.off(Hls.Events.INTERSTITIAL_ASSET_PLAYER_CREATED, onInit); + if (!hls.interstitialsManager || !hls.media) { - return; + const message = "Missing hls.interstitialsManager or hls.media"; + console.error(message); + throw new Error(message); } - clearInterval(this.intervalId_); - this.mgr_ = hls.interstitialsManager; this.media_ = hls.media; @@ -51,7 +54,10 @@ export class HlsFacade extends EventEmitter { this.initMediaListeners_(); this.initHlsListeners_(); - }); + }; + + hls.once(Hls.Events.BUFFER_CREATED, onInit); + hls.once(Hls.Events.INTERSTITIAL_ASSET_PLAYER_CREATED, onInit); } private initMediaListeners_() {