mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-10 05:05:26 +03:00
Fix preview getting wrong update time
This commit is contained in:
parent
5c3925ab50
commit
d1b1d1182f
@ -281,16 +281,12 @@ class PreviewVideoController extends PreviewController {
|
|||||||
Math.abs(seekTime - this.previewRef.current.currentTime) > 400
|
Math.abs(seekTime - this.previewRef.current.currentTime) > 400
|
||||||
) {
|
) {
|
||||||
// android/chrome has incorrect timestamps sent that are before the expected seek time
|
// android/chrome has incorrect timestamps sent that are before the expected seek time
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.seeking) {
|
if (this.seeking) {
|
||||||
this.timeToSeek = time;
|
this.timeToSeek = seekTime;
|
||||||
} else {
|
} else {
|
||||||
this.previewRef.current.currentTime = Math.max(
|
this.previewRef.current.currentTime = Math.max(0, seekTime);
|
||||||
0,
|
|
||||||
time - this.preview.start,
|
|
||||||
);
|
|
||||||
this.seeking = true;
|
this.seeking = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,16 +299,15 @@ class PreviewVideoController extends PreviewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.timeToSeek) {
|
if (this.timeToSeek) {
|
||||||
const diff =
|
const diff = Math.round(
|
||||||
Math.round(this.timeToSeek) -
|
this.timeToSeek - this.previewRef.current.currentTime,
|
||||||
Math.round(this.previewRef.current.currentTime + this.preview.start);
|
);
|
||||||
|
|
||||||
const scrubLimit = isMobile ? 1 : 0.5;
|
const scrubLimit = isMobile ? 1 : 0.5;
|
||||||
|
|
||||||
if (Math.abs(diff) >= scrubLimit) {
|
if (Math.abs(diff) >= scrubLimit) {
|
||||||
// only seek if there is an appropriate amount of time difference
|
// only seek if there is an appropriate amount of time difference
|
||||||
this.previewRef.current.currentTime =
|
this.previewRef.current.currentTime = this.timeToSeek;
|
||||||
this.timeToSeek - this.preview.start;
|
|
||||||
} else {
|
} else {
|
||||||
this.seeking = false;
|
this.seeking = false;
|
||||||
this.timeToSeek = undefined;
|
this.timeToSeek = undefined;
|
||||||
|
|||||||
@ -120,13 +120,13 @@ export default function DynamicVideoPlayer({
|
|||||||
|
|
||||||
const onTimeUpdate = useCallback(
|
const onTimeUpdate = useCallback(
|
||||||
(time: number) => {
|
(time: number) => {
|
||||||
if (!controller || !onTimestampUpdate || time == 0) {
|
if (isScrubbing || !controller || !onTimestampUpdate || time == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
onTimestampUpdate(controller.getProgress(time));
|
onTimestampUpdate(controller.getProgress(time));
|
||||||
},
|
},
|
||||||
[controller, onTimestampUpdate],
|
[controller, onTimestampUpdate, isScrubbing],
|
||||||
);
|
);
|
||||||
|
|
||||||
// state of playback player
|
// state of playback player
|
||||||
@ -176,7 +176,13 @@ export default function DynamicVideoPlayer({
|
|||||||
onTimeUpdate={onTimeUpdate}
|
onTimeUpdate={onTimeUpdate}
|
||||||
onPlayerLoaded={onPlayerLoaded}
|
onPlayerLoaded={onPlayerLoaded}
|
||||||
onClipEnded={onClipEnded}
|
onClipEnded={onClipEnded}
|
||||||
onPlaying={() => setIsLoading(false)}
|
onPlaying={() => {
|
||||||
|
if (isScrubbing) {
|
||||||
|
playerRef.current?.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsLoading(false);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{config && focusedItem && (
|
{config && focusedItem && (
|
||||||
<TimelineEventOverlay
|
<TimelineEventOverlay
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user