mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-06 05:24:11 +03:00
HLS adjustments (#20983)
* Revert "Fix HLS jumping to end of timeChunk (#20982)"
This reverts commit 301e0a1a3a.
* Never use native HLS
* Fix inverse operation
This commit is contained in:
parent
301e0a1a3a
commit
b0527df3c7
@ -6,7 +6,7 @@ import {
|
||||
useState,
|
||||
} from "react";
|
||||
import Hls from "hls.js";
|
||||
import { isAndroid, isDesktop, isMobile } from "react-device-detect";
|
||||
import { isDesktop, isMobile } from "react-device-detect";
|
||||
import { TransformComponent, TransformWrapper } from "react-zoom-pan-pinch";
|
||||
import VideoControls from "./VideoControls";
|
||||
import { VideoResolutionType } from "@/types/live";
|
||||
@ -22,7 +22,7 @@ import { useTranslation } from "react-i18next";
|
||||
import ObjectTrackOverlay from "@/components/overlay/ObjectTrackOverlay";
|
||||
|
||||
// Android native hls does not seek correctly
|
||||
const USE_NATIVE_HLS = !isAndroid;
|
||||
const USE_NATIVE_HLS = false;
|
||||
const HLS_MIME_TYPE = "application/vnd.apple.mpegurl" as const;
|
||||
const unsupportedErrorCodes = [
|
||||
MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED,
|
||||
@ -135,23 +135,6 @@ export default function HlsVideoPlayer({
|
||||
if (!useHlsCompat) {
|
||||
videoRef.current.src = currentSource.playlist;
|
||||
videoRef.current.load();
|
||||
// For native HLS, we need to seek after metadata loads since startPosition isn't supported
|
||||
if (currentSource.startPosition !== undefined) {
|
||||
videoRef.current.addEventListener(
|
||||
"loadedmetadata",
|
||||
() => {
|
||||
if (videoRef.current && currentSource.startPosition !== undefined) {
|
||||
// Clamp startPosition to video duration to prevent seeking beyond the end
|
||||
const clampedPosition = Math.min(
|
||||
currentSource.startPosition,
|
||||
videoRef.current.duration || Infinity,
|
||||
);
|
||||
videoRef.current.currentTime = clampedPosition;
|
||||
}
|
||||
},
|
||||
{ once: true },
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -111,6 +111,7 @@ export default function DynamicVideoPlayer({
|
||||
const [loadingTimeout, setLoadingTimeout] = useState<NodeJS.Timeout>();
|
||||
const [source, setSource] = useState<HlsSource>({
|
||||
playlist: `${apiHost}vod/${camera}/start/${timeRange.after}/end/${timeRange.before}/master.m3u8`,
|
||||
startPosition: startTimestamp ? startTimestamp - timeRange.after : 0,
|
||||
});
|
||||
|
||||
// start at correct time
|
||||
@ -195,8 +196,26 @@ export default function DynamicVideoPlayer({
|
||||
playerRef.current.autoplay = !isScrubbing;
|
||||
}
|
||||
|
||||
let startPosition = undefined;
|
||||
|
||||
if (startTimestamp) {
|
||||
const inpointOffset = calculateInpointOffset(
|
||||
recordingParams.after,
|
||||
(recordings || [])[0],
|
||||
);
|
||||
const idealStartPosition = Math.max(
|
||||
0,
|
||||
startTimestamp - timeRange.after - inpointOffset,
|
||||
);
|
||||
|
||||
if (idealStartPosition >= recordings[0].start_time - timeRange.after) {
|
||||
startPosition = idealStartPosition;
|
||||
}
|
||||
}
|
||||
|
||||
setSource({
|
||||
playlist: `${apiHost}vod/${camera}/start/${recordingParams.after}/end/${recordingParams.before}/master.m3u8`,
|
||||
startPosition,
|
||||
});
|
||||
|
||||
setLoadingTimeout(setTimeout(() => setIsLoading(true), 1000));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user