diff --git a/frontend/src/components/WatchPage.tsx b/frontend/src/components/WatchPage.tsx index 0aae21f3..321a17d3 100644 --- a/frontend/src/components/WatchPage.tsx +++ b/frontend/src/components/WatchPage.tsx @@ -2,6 +2,12 @@ import { useEffect, useRef, useState } from "react"; import { Download, File as FileIcon, Link2, Lock, PlayCircle } from "lucide-react"; import { Button } from "./ui/Button"; import { formatBytes } from "../lib/format"; +import { + followAudio, + handOverOnHide, + readBackgroundMode, + startPlayback, +} from "../lib/watchBackgroundAudio"; // Standalone, login-free video page for a shared /watch/ link. Rendered OUTSIDE the app // tree (no auth, no providers) — like the /privacy and /terms pages. Uses plain fetch and a tiny @@ -130,6 +136,24 @@ export default function WatchPage() { }; useMediaSession(mediaRef, meta, status === "ready"); + // PROTOTYPE (dev only): background sound for a video on iPad, `?bg=a`, `?bg=b` or `?bg=c` — see + // lib/watchBackgroundAudio. Without the param the page behaves exactly as before. + const [bgMode] = useState(() => readBackgroundMode(window.location.search)); + const audioMode = bgMode === "a" || bgMode === "b" ? bgMode : null; + const [videoEl, setVideoEl] = useState(null); + const [audioEl, setAudioEl] = useState(null); + const [started, setStarted] = useState(false); + useEffect(() => { + if (!audioMode || !videoEl || !audioEl) return; + return audioMode === "a" ? followAudio(videoEl, audioEl) : handOverOnHide(videoEl, audioEl); + }, [audioMode, videoEl, audioEl]); + // Mode "c": mount the player's wrapper first and the