Don't use createRef for patched players.
This commit is contained in:
@@ -9,9 +9,11 @@
|
||||
// available as compilation time.
|
||||
// ====================================================================
|
||||
|
||||
import { Ref, createRef, ref } from 'lit/directives/ref.js';
|
||||
import { TemplateResult, css, html } from 'lit';
|
||||
import { customElement } from 'lit/decorators.js';
|
||||
import { query } from 'lit/decorators/query.js';
|
||||
|
||||
import { FrigateCardMediaPlayer } from '../types.js';
|
||||
import { dispatchMediaShowEvent } from '../common.js';
|
||||
|
||||
customElements.whenDefined('ha-camera-stream').then(() => {
|
||||
@@ -38,7 +40,10 @@ customElements.whenDefined('ha-camera-stream').then(() => {
|
||||
@customElement('frigate-card-ha-camera-stream')
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
class FrigateCardHaCameraStream extends customElements.get('ha-camera-stream') {
|
||||
protected _playerRef: Ref<HTMLElement> = createRef();
|
||||
// Due to an obscure behavior when this card is casted, this element needs
|
||||
// to use query rather than the ref directive to find the player.
|
||||
@query('#player')
|
||||
protected _player: FrigateCardMediaPlayer;
|
||||
|
||||
// ========================================================================================
|
||||
// Minor modifications from:
|
||||
@@ -49,28 +54,28 @@ customElements.whenDefined('ha-camera-stream').then(() => {
|
||||
* Play the video.
|
||||
*/
|
||||
public play(): void {
|
||||
this._playerRef.value?.play();
|
||||
this._player?.play();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause the video.
|
||||
*/
|
||||
public pause(): void {
|
||||
this._playerRef.value?.pause();
|
||||
this._player?.pause();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mute the video.
|
||||
*/
|
||||
public mute(): void {
|
||||
this._playerRef.value?.mute();
|
||||
this._player?.mute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmute the video.
|
||||
*/
|
||||
public unmute(): void {
|
||||
this._playerRef.value?.unmute();
|
||||
this._player?.unmute();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +103,7 @@ customElements.whenDefined('ha-camera-stream').then(() => {
|
||||
if (this.stateObj.attributes.frontend_stream_type === STREAM_TYPE_HLS) {
|
||||
return this._url
|
||||
? html` <frigate-card-ha-hls-player
|
||||
${ref(this._playerRef)}
|
||||
id="player"
|
||||
?autoplay=${false}
|
||||
playsinline
|
||||
.allowExoPlayer=${this.allowExoPlayer}
|
||||
@@ -111,7 +116,7 @@ customElements.whenDefined('ha-camera-stream').then(() => {
|
||||
}
|
||||
if (this.stateObj.attributes.frontend_stream_type === STREAM_TYPE_WEB_RTC) {
|
||||
return html`<frigate-card-ha-web-rtc-player
|
||||
${ref(this._playerRef)}
|
||||
id="player"
|
||||
?autoplay=${false}
|
||||
playsinline
|
||||
.muted=${this.muted}
|
||||
|
||||
Reference in New Issue
Block a user