From a85f34bfa07f709cf366cf20aca39d92f062d2e9 Mon Sep 17 00:00:00 2001 From: Bitaru Date: Tue, 21 May 2024 11:23:25 +0100 Subject: [PATCH] fix: live event seek to the end --- src/components/video-container/Video-container.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/video-container/Video-container.component.ts b/src/components/video-container/Video-container.component.ts index d030ca1..fd6c82a 100644 --- a/src/components/video-container/Video-container.component.ts +++ b/src/components/video-container/Video-container.component.ts @@ -19,8 +19,6 @@ import "../buttons/Play"; import { subtitlesController, SubtitlesController } from "./subtitles"; import { sourcesController, SourcesController } from "./sources"; -const END_OF_STREAM_SECONDS = 99999; - const INIT_NATIVE_HLS_RE = /^((?!chrome|android).)*safari/i; // In Safari on live streams video.duration = Infinity @@ -176,7 +174,9 @@ export class VideoContainer extends LitElement { dispatch(this, Types.Action.live, { live: true }); if (this.played) { window.requestAnimationFrame(() => { - this.videos[0].currentTime = END_OF_STREAM_SECONDS; + const seekable = this.videos[0].seekable; + const end = seekable?.length ? seekable.end(0) - 10 : 999999; + this.videos[0].currentTime = end; this.play(); }); }