mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 17:46:06 +00:00
fix(player): stop YouTube iframe re-init loop
This commit is contained in:
+1
-1
@@ -45,5 +45,5 @@ next-env.d.ts
|
|||||||
|
|
||||||
# Progress (Internal Tracking)
|
# Progress (Internal Tracking)
|
||||||
PROGRESS.md
|
PROGRESS.md
|
||||||
OPTIMIZATION.md
|
OPTIMIZATIONS.md
|
||||||
.kilocode
|
.kilocode
|
||||||
@@ -313,6 +313,7 @@ export function VideoPageContent({ mode, videoId, projectId: propProjectId }: Vi
|
|||||||
// Watch progress state
|
// Watch progress state
|
||||||
const [savedProgress, setSavedProgress] = useState<number | null>(null);
|
const [savedProgress, setSavedProgress] = useState<number | null>(null);
|
||||||
const [showResumePrompt, setShowResumePrompt] = useState(false);
|
const [showResumePrompt, setShowResumePrompt] = useState(false);
|
||||||
|
const videoDurationRef = useRef(0);
|
||||||
const progressSaveTimerRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
const progressSaveTimerRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||||
const progressDebounceTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
const progressDebounceTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
const progressWriteInFlightRef = useRef(false);
|
const progressWriteInFlightRef = useRef(false);
|
||||||
@@ -845,7 +846,7 @@ export function VideoPageContent({ mode, videoId, projectId: propProjectId }: Vi
|
|||||||
const progress = Math.max(0, input.progress);
|
const progress = Math.max(0, input.progress);
|
||||||
if (progress <= 0) return;
|
if (progress <= 0) return;
|
||||||
|
|
||||||
const duration = Math.max(0, input.duration ?? videoDuration ?? 0);
|
const duration = Math.max(0, input.duration ?? videoDurationRef.current ?? 0);
|
||||||
const force = input.force ?? false;
|
const force = input.force ?? false;
|
||||||
|
|
||||||
if (!force && Math.abs(progress - lastSavedProgressRef.current) < 2) {
|
if (!force && Math.abs(progress - lastSavedProgressRef.current) < 2) {
|
||||||
@@ -878,7 +879,7 @@ export function VideoPageContent({ mode, videoId, projectId: propProjectId }: Vi
|
|||||||
progressDebounceTimerRef.current = null;
|
progressDebounceTimerRef.current = null;
|
||||||
void flushScheduledWatchProgress();
|
void flushScheduledWatchProgress();
|
||||||
}, 800);
|
}, 800);
|
||||||
}, [video?.isAuthenticated, activeVersionId, videoDuration, flushScheduledWatchProgress]);
|
}, [video?.isAuthenticated, activeVersionId, flushScheduledWatchProgress]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
@@ -889,6 +890,10 @@ export function VideoPageContent({ mode, videoId, projectId: propProjectId }: Vi
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
videoDurationRef.current = videoDuration;
|
||||||
|
}, [videoDuration]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
lastSavedProgressRef.current = 0;
|
lastSavedProgressRef.current = 0;
|
||||||
pendingProgressPayloadRef.current = null;
|
pendingProgressPayloadRef.current = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user