Improve seek labeling.

This commit is contained in:
Dermot Duffy
2022-06-04 11:04:38 -07:00
parent 7ebada9aa5
commit c282735a3b
5 changed files with 32 additions and 19 deletions
+7 -1
View File
@@ -9,7 +9,7 @@ import thumbnailStyle from '../scss/thumbnail.scss';
import type {
FrigateBrowseMediaSource,
FrigateEvent,
FrigateRecording,
FrigateRecording
} from '../types.js';
import { stopEventFromActivatingCardWideActions } from '../utils/action.js';
import { prettifyTitle } from '../utils/basic.js';
@@ -102,6 +102,12 @@ export class FrigateCardThumbnailDetailsRecording extends LitElement {
}
return html`<div class="left">
<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 class="right">
<span class="larger">${this.recording.events}</span>
+4 -3
View File
@@ -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 {
add,
@@ -637,7 +635,10 @@ export class FrigateCardTimelineCore extends LitElement {
start_time: getUnixTime(startHour),
end_time: getUnixTime(endHour),
events: hourData.events,
...(isMatchingHour && { play_time: seekSeconds }),
...(isMatchingHour && {
seek_seconds: seekSeconds,
seek_time: time.getTime() / 1000,
}),
},
},
),
+11 -8
View File
@@ -684,14 +684,14 @@ export class FrigateCardViewerCarousel extends FrigateCardMediaCarousel {
super._selectSlideMediaShowHandler();
// If this is a recording and play is desired to be started from a
// particular point, seek to that point.
if (this.view?.media?.frigate?.recording?.play_time) {
const player = this._getPlayer();
if (player) {
player.seek(this.view.media.frigate.recording.play_time);
// TODO: Fix this bug.
console.info(`Seeking on ${this.view.media.media_content_id}`);
}
// particular point, seek to that point. Use the media off the slide itself
// -- when the slide is changed, the media show event may be dispatched
// before this.view has been updated to reflect the new selection.
const player = this._getPlayer() as FrigateCardMediaPlayer & {
media?: FrigateBrowseMediaSource;
};
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;
}
// The media is attached to the player as '.media' which is used in
// `_selectSlideMediaShowHandler` (and not used by the player itself).
return html`
<div class="embla__slide">
${mediaToRender.media_content_type === 'video'
@@ -730,6 +732,7 @@ export class FrigateCardViewerCarousel extends FrigateCardMediaCarousel {
url=${ifDefined(
lazyLoad ? undefined : this._canonicalizeHAURL(resolvedMedia?.url),
)}
.media=${mediaToRender}
.hass=${this.hass}
@frigate-card:media-show=${(e: CustomEvent<MediaShowInfo>) =>
this._mediaShowEventHandler(slideIndex, e)}
+2 -1
View File
@@ -295,7 +295,8 @@
"score": "Score"
},
"recording": {
"events": "Events"
"events": "Events",
"seek": "Seek"
},
"thumbnail": {
"retain_indefinitely": "Event will be indefinitely retained",
+5 -3
View File
@@ -1246,9 +1246,11 @@ export interface FrigateRecording {
end_time: number;
events: number;
// The number of seconds at which this recording should be initially played
// from.
play_time?: number;
// Specifies the point at which this recording should be played, the
// seek_time is the date of the desired play point, and seek_seconds is the
// number of seconds to seek to reach that point.
seek_time?: number;
seek_seconds?: number;
}
export interface FrigateBrowseMediaSource extends BrowseMediaSource {