Improve seek labeling.
This commit is contained in:
@@ -9,7 +9,7 @@ import thumbnailStyle from '../scss/thumbnail.scss';
|
|||||||
import type {
|
import type {
|
||||||
FrigateBrowseMediaSource,
|
FrigateBrowseMediaSource,
|
||||||
FrigateEvent,
|
FrigateEvent,
|
||||||
FrigateRecording,
|
FrigateRecording
|
||||||
} from '../types.js';
|
} from '../types.js';
|
||||||
import { stopEventFromActivatingCardWideActions } from '../utils/action.js';
|
import { stopEventFromActivatingCardWideActions } from '../utils/action.js';
|
||||||
import { prettifyTitle } from '../utils/basic.js';
|
import { prettifyTitle } from '../utils/basic.js';
|
||||||
@@ -102,6 +102,12 @@ export class FrigateCardThumbnailDetailsRecording extends LitElement {
|
|||||||
}
|
}
|
||||||
return html`<div class="left">
|
return html`<div class="left">
|
||||||
<div class="larger">${prettifyTitle(this.recording.camera) || ''}</div>
|
<div class="larger">${prettifyTitle(this.recording.camera) || ''}</div>
|
||||||
|
${this.recording.seek_time
|
||||||
|
? html` <div>
|
||||||
|
<span class="heading">${localize('recording.seek')}</span>
|
||||||
|
<span>${format(fromUnixTime(this.recording.seek_time), 'HH:mm:ss')}</span>
|
||||||
|
</div>`
|
||||||
|
: html``}
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<span class="larger">${this.recording.events}</span>
|
<span class="larger">${this.recording.events}</span>
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// TODO: In viewer, the seek is being applied to the 2nd media. Change away from play_time?
|
|
||||||
|
|
||||||
import { HomeAssistant } from 'custom-card-helpers';
|
import { HomeAssistant } from 'custom-card-helpers';
|
||||||
import {
|
import {
|
||||||
add,
|
add,
|
||||||
@@ -637,7 +635,10 @@ export class FrigateCardTimelineCore extends LitElement {
|
|||||||
start_time: getUnixTime(startHour),
|
start_time: getUnixTime(startHour),
|
||||||
end_time: getUnixTime(endHour),
|
end_time: getUnixTime(endHour),
|
||||||
events: hourData.events,
|
events: hourData.events,
|
||||||
...(isMatchingHour && { play_time: seekSeconds }),
|
...(isMatchingHour && {
|
||||||
|
seek_seconds: seekSeconds,
|
||||||
|
seek_time: time.getTime() / 1000,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -684,14 +684,14 @@ export class FrigateCardViewerCarousel extends FrigateCardMediaCarousel {
|
|||||||
super._selectSlideMediaShowHandler();
|
super._selectSlideMediaShowHandler();
|
||||||
|
|
||||||
// If this is a recording and play is desired to be started from a
|
// If this is a recording and play is desired to be started from a
|
||||||
// particular point, seek to that point.
|
// particular point, seek to that point. Use the media off the slide itself
|
||||||
if (this.view?.media?.frigate?.recording?.play_time) {
|
// -- when the slide is changed, the media show event may be dispatched
|
||||||
const player = this._getPlayer();
|
// before this.view has been updated to reflect the new selection.
|
||||||
if (player) {
|
const player = this._getPlayer() as FrigateCardMediaPlayer & {
|
||||||
player.seek(this.view.media.frigate.recording.play_time);
|
media?: FrigateBrowseMediaSource;
|
||||||
// TODO: Fix this bug.
|
};
|
||||||
console.info(`Seeking on ${this.view.media.media_content_id}`);
|
if (player && player.media && player.media.frigate?.recording?.seek_seconds) {
|
||||||
}
|
player.seek(player.media.frigate.recording.seek_seconds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -716,6 +716,8 @@ export class FrigateCardViewerCarousel extends FrigateCardMediaCarousel {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The media is attached to the player as '.media' which is used in
|
||||||
|
// `_selectSlideMediaShowHandler` (and not used by the player itself).
|
||||||
return html`
|
return html`
|
||||||
<div class="embla__slide">
|
<div class="embla__slide">
|
||||||
${mediaToRender.media_content_type === 'video'
|
${mediaToRender.media_content_type === 'video'
|
||||||
@@ -730,6 +732,7 @@ export class FrigateCardViewerCarousel extends FrigateCardMediaCarousel {
|
|||||||
url=${ifDefined(
|
url=${ifDefined(
|
||||||
lazyLoad ? undefined : this._canonicalizeHAURL(resolvedMedia?.url),
|
lazyLoad ? undefined : this._canonicalizeHAURL(resolvedMedia?.url),
|
||||||
)}
|
)}
|
||||||
|
.media=${mediaToRender}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@frigate-card:media-show=${(e: CustomEvent<MediaShowInfo>) =>
|
@frigate-card:media-show=${(e: CustomEvent<MediaShowInfo>) =>
|
||||||
this._mediaShowEventHandler(slideIndex, e)}
|
this._mediaShowEventHandler(slideIndex, e)}
|
||||||
|
|||||||
@@ -295,7 +295,8 @@
|
|||||||
"score": "Score"
|
"score": "Score"
|
||||||
},
|
},
|
||||||
"recording": {
|
"recording": {
|
||||||
"events": "Events"
|
"events": "Events",
|
||||||
|
"seek": "Seek"
|
||||||
},
|
},
|
||||||
"thumbnail": {
|
"thumbnail": {
|
||||||
"retain_indefinitely": "Event will be indefinitely retained",
|
"retain_indefinitely": "Event will be indefinitely retained",
|
||||||
|
|||||||
+5
-3
@@ -1246,9 +1246,11 @@ export interface FrigateRecording {
|
|||||||
end_time: number;
|
end_time: number;
|
||||||
events: number;
|
events: number;
|
||||||
|
|
||||||
// The number of seconds at which this recording should be initially played
|
// Specifies the point at which this recording should be played, the
|
||||||
// from.
|
// seek_time is the date of the desired play point, and seek_seconds is the
|
||||||
play_time?: number;
|
// number of seconds to seek to reach that point.
|
||||||
|
seek_time?: number;
|
||||||
|
seek_seconds?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FrigateBrowseMediaSource extends BrowseMediaSource {
|
export interface FrigateBrowseMediaSource extends BrowseMediaSource {
|
||||||
|
|||||||
Reference in New Issue
Block a user