Allow default media controls to be hidden.

This commit is contained in:
Dermot Duffy
2023-05-14 20:00:23 -07:00
parent ffb0e8ac15
commit 972a0999fb
23 changed files with 909 additions and 815 deletions
+9 -3
View File
@@ -41,6 +41,9 @@ export class FrigateCardLiveWebRTCCard
@property({ attribute: false })
public cardWideConfig?: CardWideConfig;
@property({ attribute: true, type: Boolean })
public controls = false;
protected hass?: HomeAssistant;
// A task to await the load of the WebRTC component.
@@ -79,10 +82,10 @@ export class FrigateCardLiveWebRTCCard
}
}
public async setControls(controls: boolean): Promise<void> {
public async setControls(controls?: boolean): Promise<void> {
const player = this._getPlayer();
if (player) {
player.controls = controls;
player.controls = controls ?? this.controls;
}
}
@@ -189,7 +192,9 @@ export class FrigateCardLiveWebRTCCard
const video = this._getPlayer();
if (video) {
video.onloadeddata = () => {
hideMediaControlsTemporarily(video, MEDIA_LOAD_CONTROLS_HIDE_SECONDS);
if (this.controls) {
hideMediaControlsTemporarily(video, MEDIA_LOAD_CONTROLS_HIDE_SECONDS);
}
dispatchMediaLoadedEvent(this, video, {
player: this,
capabilities: {
@@ -201,6 +206,7 @@ export class FrigateCardLiveWebRTCCard
video.onplay = () => dispatchMediaPlayEvent(this);
video.onpause = () => dispatchMediaPauseEvent(this);
video.onvolumechange = () => dispatchMediaVolumeChangeEvent(this);
video.controls = this.controls;
}
});
}