diff --git a/src/App.tsx b/src/App.tsx index 76d02a2..167f4a6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -103,6 +103,9 @@ function AppBody() { const vis = (k: Tab) => (tab === k ? "absolute inset-0" : "absolute inset-0 invisible pointer-events-none"); const pageActive = stack.length === 0 && !loginOpen; const bottomInset = platform === "android" ? (fs ? 0 : 48) : 14; + /* 栈页(从搜索/分类/我的进入的播放页、图文页)不显示底栏: + 底栏会盖住评论抽屉的输入框,且这些页面本身是沉浸的 */ + const stackInset = platform === "android" ? (fs ? 0 : 20) : 14; return (
@@ -115,11 +118,11 @@ function AppBody() { {stack.map((p, i) => (
- +
))} - {platform === "android" && !fs && } + {platform === "android" && !fs && stack.length === 0 && }
); diff --git a/src/components/Feed.tsx b/src/components/Feed.tsx index 0089a3a..3ead644 100644 --- a/src/components/Feed.tsx +++ b/src/components/Feed.tsx @@ -57,6 +57,23 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind const setTheater = store.setTheater; const fs = store.fs; const setFs = store.setFs; + + /* 桌面:鼠标闲置 2.8s 自动隐藏播放器 UI(沉浸) */ + const [idle, setIdle] = useState(false); + const idleTimer = useRef(undefined); + const wake = useCallback(() => { + setIdle(false); + window.clearTimeout(idleTimer.current); + idleTimer.current = window.setTimeout(() => setIdle(true), 2800); + }, []); + useEffect(() => { + if (!isDesktop) return undefined; + wake(); + return () => window.clearTimeout(idleTimer.current); + }, [isDesktop, wake]); + useEffect(() => { + if (paused) { setIdle(false); window.clearTimeout(idleTimer.current); } + }, [paused]); const [fullscreen, setFullscreen] = useState(false); const [heartBurst, setHeartBurst] = useState(0); /* —— 移动端手势 —— */ @@ -442,7 +459,9 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind } return ( -
+
{ if (isDesktop) wake(); }}> {/* 氛围背景 */}
{posterUrl && } @@ -459,7 +478,8 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind
0 && vsize.w > vsize.h) ? "contain" : "cover"} onClick={() => { if (isDesktop) videoRef.current?.toggle(); }} onTime={setTime} onDuration={setDuration} @@ -644,7 +664,7 @@ export default function Feed({ videoIds, startIndex = 0, title = "", mode, kind e.ep_num === curEp + 1) && index >= videoIds.length - 1} nextTitle={episodes.some((e) => e.ep_num === curEp + 1) ? "下一集 E" : "下一部 ↓"} onToggle={() => videoRef.current?.toggle()} diff --git a/src/components/VideoSurface.tsx b/src/components/VideoSurface.tsx index 5226a6d..cbb756b 100644 --- a/src/components/VideoSurface.tsx +++ b/src/components/VideoSurface.tsx @@ -20,6 +20,9 @@ type Props = { muted?: boolean; loop?: boolean; fit?: "contain" | "cover"; + /** 换源后重新套用,避免切集时音量/倍速被浏览器重置 */ + volume?: number; + rate?: number; onTime?: (t: number) => void; onDuration?: (d: number) => void; onSize?: (w: number, h: number) => void; @@ -34,7 +37,7 @@ type Props = { /** 只负责「播」:hls.js + video 元素,控制条由外层渲染。 */ const VideoSurface = forwardRef(function VideoSurface( - { src, poster, autoPlay = true, muted = false, loop = false, fit = "contain", + { src, poster, autoPlay = true, muted = false, loop = false, fit = "contain", volume = 1, rate = 1, onTime, onDuration, onSize, onPlaying, onPause, onWaiting, onEnded, onError, onClick, className = "" }, ref, ) { @@ -67,6 +70,16 @@ const VideoSurface = forwardRef(function VideoSurface( const url = proxied ? src : playlist(src); const useHls = !url.includes("/seg?u="); + /* 换源时先把音量/倍速套回去:hls 重新 attach 后浏览器会把它们重置成默认值 */ + const applySettings = () => { + const v = videoRef.current; + if (!v) return; + v.volume = volume; + v.muted = muted; + v.playbackRate = rate; + }; + applySettings(); + if (useHls && Hls.isSupported()) { const hls = new Hls({ enableWorker: true, @@ -101,6 +114,14 @@ const VideoSurface = forwardRef(function VideoSurface( }, [src]); useEffect(() => { if (videoRef.current) videoRef.current.muted = muted; }, [muted]); + useEffect(() => { if (videoRef.current) videoRef.current.volume = volume; }, [volume]); + useEffect(() => { if (videoRef.current) videoRef.current.playbackRate = rate; }, [rate]); + + const reapply = (v: HTMLVideoElement) => { + v.volume = volume; + v.muted = muted; + v.playbackRate = rate; + }; return (