Skip to content

Commit

Permalink
Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
matvp91 committed Dec 6, 2024
1 parent 98e094b commit 45dde29
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions fixtures/media-chrome/superstreamer-video-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MediaTracksMixin } from "media-tracks";

function getTemplateHTML() {
return `
<style>
<style>
:host {
width: 100%;
height: 100%;
Expand All @@ -26,6 +26,8 @@ class SuperstreamerVideoElement extends MediaTracksMixin(

#player;

#readyState = 0;

get src() {
return this.getAttribute("src");
}
Expand All @@ -51,13 +53,13 @@ class SuperstreamerVideoElement extends MediaTracksMixin(
this.shadowRoot.innerHTML = getTemplateHTML();
}

this.#readyState = 0;
this.dispatchEvent(new Event("emptied"));

if (!this.#player) {
const container = this.shadowRoot.querySelector(".container");
const player = (this.#player = new HlsPlayer(container));

// TODO: Remove this.
Object.assign(window, { player });

player.on(Events.PLAYHEAD_CHANGE, () => {
switch (player.playhead) {
case "play":
Expand All @@ -84,10 +86,20 @@ class SuperstreamerVideoElement extends MediaTracksMixin(
this.dispatchEvent(new Event("loadedmetadata"));
this.dispatchEvent(new Event("durationchange"));
this.dispatchEvent(new Event("loadcomplete"));
this.#readyState = 1;
});

player.on(Events.STARTED, () => {
this.#readyState = 3;
});
}

this.#player.load(this.src);

// TODO: Remove this.
Object.assign(window, {
player: this.#player,
});
}

get currentTime() {
Expand All @@ -114,7 +126,7 @@ class SuperstreamerVideoElement extends MediaTracksMixin(
}

get readyState() {
return 3;
return this.#readyState;
}

get muted() {
Expand Down

0 comments on commit 45dde29

Please sign in to comment.