Skip to content

Commit

Permalink
fix: Rely on HLSjs events instead of polling
Browse files Browse the repository at this point in the history
  • Loading branch information
matvp91 committed Sep 11, 2024
1 parent 7ae992b commit 45b1084
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/dashboard/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
16 changes: 11 additions & 5 deletions packages/player/lib/facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,27 @@ export class HlsFacade extends EventEmitter<Events> {
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;

this.initState_();

this.initMediaListeners_();
this.initHlsListeners_();
});
};

hls.once(Hls.Events.BUFFER_CREATED, onInit);
hls.once(Hls.Events.INTERSTITIAL_ASSET_PLAYER_CREATED, onInit);
}

private initMediaListeners_() {
Expand Down

0 comments on commit 45b1084

Please sign in to comment.