Autoformating and cleanup
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
export const MediaPlayerMixin = (SuperClass) => {
|
||||
return class MediaPlayerMixinClass extends SuperClass {
|
||||
|
||||
public player;
|
||||
private _player_enabled;
|
||||
|
||||
@@ -14,7 +13,9 @@ export const MediaPlayerMixin = (SuperClass) => {
|
||||
this.player.addEventListener(ev, () => this._player_update());
|
||||
}
|
||||
|
||||
window.addEventListener("pointerdown", () => {
|
||||
window.addEventListener(
|
||||
"pointerdown",
|
||||
() => {
|
||||
this._player_enabled = true;
|
||||
if (!this.player.ended) this.player.play();
|
||||
},
|
||||
@@ -26,7 +27,9 @@ export const MediaPlayerMixin = (SuperClass) => {
|
||||
this.player.src = ev.detail.media_content_id;
|
||||
this.player.play();
|
||||
});
|
||||
this.addEventListener("command-player-pause", (ev) => this.player.pause());
|
||||
this.addEventListener("command-player-pause", (ev) =>
|
||||
this.player.pause()
|
||||
);
|
||||
this.addEventListener("command-player-stop", (ev) => {
|
||||
this.player.src = null;
|
||||
this.player.pause();
|
||||
@@ -38,34 +41,30 @@ export const MediaPlayerMixin = (SuperClass) => {
|
||||
this.addEventListener("command-player-mute", (ev) => {
|
||||
if (ev.detail?.mute !== undefined)
|
||||
this.player.muted = Boolean(ev.detail.mute);
|
||||
else
|
||||
this.player.muted = !this.player.muted;
|
||||
else this.player.muted = !this.player.muted;
|
||||
});
|
||||
|
||||
this.connectionPromise.then(() => this._player_update());
|
||||
}
|
||||
|
||||
private _player_update() {
|
||||
const state =
|
||||
this._player_enabled
|
||||
const state = this._player_enabled
|
||||
? this.player.src
|
||||
? this.player.ended
|
||||
? "stopped"
|
||||
: this.player.paused
|
||||
? "paused"
|
||||
: "playing"
|
||||
? "paused"
|
||||
: "playing"
|
||||
: "stopped"
|
||||
: "unavailable"
|
||||
;
|
||||
: "unavailable";
|
||||
this.sendUpdate({
|
||||
player: {
|
||||
volume: this.player.volume,
|
||||
muted: this.player.muted,
|
||||
src: this.player.src,
|
||||
state,
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user