mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-08 20:25:26 +03:00
Get scrubbing to next preview working
This commit is contained in:
parent
81f0c68b85
commit
5cbc0443f7
@ -262,6 +262,7 @@ export default function DynamicVideoPlayer({
|
||||
previewRef.current = player;
|
||||
player.pause();
|
||||
player.on("seeked", () => controller.finishedSeeking());
|
||||
player.on("loadeddata", () => controller.previewReady())
|
||||
}}
|
||||
onDispose={() => {
|
||||
previewRef.current = undefined;
|
||||
@ -291,6 +292,7 @@ export class DynamicVideoController {
|
||||
private preview: Preview | undefined = undefined;
|
||||
private timeToSeek: number | undefined = undefined;
|
||||
private seeking = false;
|
||||
private readyToScrub = true;
|
||||
|
||||
constructor(
|
||||
playerRef: MutableRefObject<Player | undefined>,
|
||||
@ -410,25 +412,40 @@ export class DynamicVideoController {
|
||||
|
||||
if (time > this.preview.end) {
|
||||
if (this.playerMode == "scrubbing") {
|
||||
this.fireClipEndEvent();
|
||||
this.playerMode = "playback";
|
||||
this.setScrubbing(false);
|
||||
this.timeToSeek = undefined;
|
||||
this.seeking = false;
|
||||
this.readyToScrub = false;
|
||||
this.fireClipEndEvent();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.readyToScrub) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.playerMode != "scrubbing") {
|
||||
this.playerMode = "scrubbing";
|
||||
this.playerRef.current?.pause();
|
||||
this.setScrubbing(true);
|
||||
}
|
||||
|
||||
console.log(
|
||||
"scrubbing to " +
|
||||
time +
|
||||
" with current seek time " +
|
||||
this.timeToSeek +
|
||||
" and current player time " +
|
||||
this.previewRef.current?.currentTime()
|
||||
);
|
||||
|
||||
if (this.seeking) {
|
||||
this.timeToSeek = time;
|
||||
} else {
|
||||
this.previewRef.current?.currentTime(time - this.preview.start);
|
||||
console.log("player is being seeked to " + Math.max(0, time - this.preview.start))
|
||||
this.previewRef.current?.currentTime(Math.max(0, time - this.preview.start));
|
||||
this.seeking = true;
|
||||
}
|
||||
}
|
||||
@ -449,4 +466,10 @@ export class DynamicVideoController {
|
||||
this.seeking = false;
|
||||
}
|
||||
}
|
||||
|
||||
previewReady() {
|
||||
console.log("the preview is ready")
|
||||
this.previewRef.current?.pause()
|
||||
this.readyToScrub = true;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user