diff --git a/src/frigate-hass-card.ts b/src/frigate-hass-card.ts
index 5439345f..896dacd9 100644
--- a/src/frigate-hass-card.ts
+++ b/src/frigate-hass-card.ts
@@ -45,7 +45,8 @@ import dayjs from 'dayjs';
import dayjs_utc from 'dayjs/plugin/utc';
import dayjs_timezone from 'dayjs/plugin/timezone';
-const URL_TROUBLESHOOTING = "https://github.com/dermotduffy/frigate-hass-card#troubleshooting";
+const URL_TROUBLESHOOTING =
+ 'https://github.com/dermotduffy/frigate-hass-card#troubleshooting';
// Load dayjs plugins.
dayjs.extend(dayjs_timezone);
@@ -431,8 +432,7 @@ export class FrigateCard extends LitElement {
): TemplateResult {
return html`
-
-
+
${message ? html` ${message}` : ''}
`;
@@ -442,7 +442,8 @@ export class FrigateCard extends LitElement {
protected _renderError(error: string): TemplateResult {
return this._renderAttentionIcon(
'mdi:alert-circle',
- html`${error}. See troubleshooting.`);
+ html`${error}. See troubleshooting.`,
+ );
}
// Generate a human-readable title from an event.
@@ -606,7 +607,7 @@ export class FrigateCard extends LitElement {
if (!event.has_clip) {
return null;
}
- return `${this.config.frigate_url}/vod/event/${event.id}/index.m3u8`
+ return `${this.config.frigate_url}/vod/event/${event.id}/index.m3u8`;
}
protected _getSnapshotURLFromEvent(event: FrigateEvent): string | null {
@@ -654,24 +655,49 @@ export class FrigateCard extends LitElement {
this._eventBeingShown = event;
return html`
-
+
`;
}
+ public updated(): void {
+ this.updateComplete.then(() => {
+ // DOM elements are not always present until after updateComplete promise
+ // is resolved. Note that children of children (i.e. the underlying video
+ // element) is not always present even when the promise returns, so
+ // capture the event at the upper shadow root instead.
+ const hls_player = this.renderRoot
+ ?.querySelector('ha-card')
+ ?.querySelector('ha-hls-player');
+
+ if (hls_player) {
+ hls_player.shadowRoot?.addEventListener(
+ 'play',
+ () => {
+ this._clipPlaying = true;
+ },
+ true,
+ );
+ hls_player.shadowRoot?.addEventListener(
+ 'pause',
+ () => {
+ this._clipPlaying = true;
+ },
+ true,
+ );
+ }
+ });
+ }
+
// Render a snapshot.
protected async _renderSnapshotViewer(): Promise {
let event: FrigateEvent, events: FrigateGetEventsResponse;