diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index 3b27fd7..313608f 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -4,7 +4,7 @@ import { AlertCircle, Cloud, Heart, Loader2, Router, Sparkles, X } from 'lucide-react'; import { useRouter, useSearchParams } from 'next/navigation'; -import { Suspense, useEffect, useRef, useState } from 'react'; +import { Suspense, useEffect, useMemo, useRef, useState } from 'react'; import { getAuthInfoFromBrowserCookie } from '@/lib/auth'; import { @@ -633,12 +633,29 @@ function PlayPageClient() { // 搜索所需信息 const [searchTitle] = useState(searchParams.get('stitle') || ''); const [searchType] = useState(searchParams.get('stype') || ''); - const [episodeProgressContentKey] = useState(() => - buildEpisodeProgressContentKey({ - title: searchTitle || searchParams.get('title') || '', - year: searchParams.get('year') || '', + const [initialEpisodeProgressTitle] = useState( + searchTitle || searchParams.get('title') || '' + ); + const [initialEpisodeProgressYear] = useState( + searchParams.get('year') || '' + ); + const episodeProgressContentKey = useMemo( + () => + buildEpisodeProgressContentKey({ + doubanId: videoDoubanId || detail?.douban_id, + tmdbId: detail?.tmdb_id, + title: initialEpisodeProgressTitle, + year: initialEpisodeProgressYear, + searchType, + }), + [ + detail?.douban_id, + detail?.tmdb_id, + initialEpisodeProgressTitle, + initialEpisodeProgressYear, searchType, - }) + videoDoubanId, + ] ); // 是否需要优选 @@ -2719,13 +2736,13 @@ function PlayPageClient() { const ensureVideoSource = (video: HTMLVideoElement | null, url: string) => { if (!video || !url) return; const sources = Array.from(video.getElementsByTagName('source')); + const isHlsJsActive = !!(video as any).hls; const isHlsLikeSource = - !!(video as any).hls || /\.m3u8?($|\?)/i.test(url) || url.includes('/api/proxy-m3u8') || url.includes('/api/proxy/vod/m3u8'); - if (isHlsLikeSource) { + if (isHlsJsActive && isHlsLikeSource) { // HLS 由 hls.js 接管时,不能再给