From 2cb54d702173b91386f3be11c99401bfeab452fa Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 10 Mar 2026 20:09:33 +0200 Subject: [PATCH] fix(video_player): loop can get out of sync with external control --- apps/client/src/widgets/type_widgets/file/Video.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/client/src/widgets/type_widgets/file/Video.tsx b/apps/client/src/widgets/type_widgets/file/Video.tsx index 2ab4c76e50..ce45f059d6 100644 --- a/apps/client/src/widgets/type_widgets/file/Video.tsx +++ b/apps/client/src/widgets/type_widgets/file/Video.tsx @@ -283,7 +283,17 @@ function PlaybackSpeed({ videoRef }: { videoRef: RefObject }) } function LoopButton({ videoRef }: { videoRef: RefObject }) { - const [loop, setLoop] = useState(false); + const [loop, setLoop] = useState(() => videoRef.current?.loop ?? false); + + useEffect(() => { + const video = videoRef.current; + if (!video) return; + setLoop(video.loop); + + const observer = new MutationObserver(() => setLoop(video.loop)); + observer.observe(video, { attributes: true, attributeFilter: ["loop"] }); + return () => observer.disconnect(); + }, []); const toggle = () => { const video = videoRef.current;