From 54cdd87bccbbde423b2f61b718d5eddd223c47cb Mon Sep 17 00:00:00 2001 From: mtvpls Date: Tue, 3 Feb 2026 11:17:49 +0800 Subject: [PATCH] =?UTF-8?q?weblive=E8=A7=82=E5=BD=B1=E5=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/web-live/page.tsx | 26 +++++++-- src/hooks/useWebLiveSync.ts | 104 ++++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 src/hooks/useWebLiveSync.ts diff --git a/src/app/web-live/page.tsx b/src/app/web-live/page.tsx index 2ae6552..1a9dceb 100644 --- a/src/app/web-live/page.tsx +++ b/src/app/web-live/page.tsx @@ -3,6 +3,8 @@ import { AlertTriangle,Radio } from 'lucide-react'; import { useEffect, useRef, useState } from 'react'; +import { useWebLiveSync } from '@/hooks/useWebLiveSync'; + import PageLayout from '@/components/PageLayout'; let Artplayer: any = null; @@ -27,6 +29,22 @@ export default function WebLivePage() { const [selectedPlatform, setSelectedPlatform] = useState(null); const [isWebLiveEnabled, setIsWebLiveEnabled] = useState(null); + // 观影室同步功能 + const webLiveSync = useWebLiveSync({ + currentSourceKey: currentSource?.key || '', + currentSourceName: currentSource?.name || '', + currentSourcePlatform: currentSource?.platform || '', + currentSourceRoomId: currentSource?.roomId || '', + onSourceChange: (sourceKey, platform, roomId) => { + // 房员接收到直播源切换指令 + if (!sources || !Array.isArray(sources)) return; + const source = sources.find(s => s.key === sourceKey); + if (source) { + handleSourceClick(source); + } + }, + }); + useEffect(() => { const meta = document.createElement('meta'); meta.name = 'referrer'; @@ -419,7 +437,7 @@ export default function WebLivePage() { {/* 外部播放器按钮 */} - {currentSource && ( + {currentSource && !webLiveSync.isInRoom && (
@@ -653,7 +671,8 @@ export default function WebLivePage() {