Clean up seek handler.

This commit is contained in:
Dermot Duffy
2023-08-13 12:37:20 -07:00
parent b4595867b3
commit c665f1b351
2 changed files with 10 additions and 9 deletions
+8 -8
View File
@@ -541,24 +541,24 @@ export class FrigateCardViewerCarousel extends LitElement {
return;
}
const selectedMedia = this._media[this.selected];
if (!selectedMedia) {
const player = this._getPlayer();
if (!selectedMedia || !player) {
return;
}
const seekTimeInMedia = selectedMedia.includesTime(seek);
setOrRemoveAttribute(this, !seekTimeInMedia, 'unseekable');
if (!seekTimeInMedia) {
this._getPlayer()?.pause();
} else {
this._getPlayer()?.play();
if (!seekTimeInMedia && !player.isPaused()) {
player.pause();
} else if (seekTimeInMedia && player.isPaused()) {
player.play();
}
const seekTime =
(await this.cameraManager?.getMediaSeekTime(this.hass, selectedMedia, seek)) ??
null;
const player = this._getPlayer();
if (player && seekTime !== null) {
if (seekTime !== null) {
player.seek(seekTime);
}
}