From 86b2e704e9ec47efbeec401bc7dd8ac8aace1b84 Mon Sep 17 00:00:00 2001 From: "Carlos (Almeira)" Date: Mon, 30 Mar 2026 08:55:51 -0500 Subject: [PATCH] refactor: refine global player visibility and active signal labels --- src/app/layout.tsx | 2 +- src/components/media/GlobalPlayer.tsx | 29 ++++++++++++++++++++------- src/store/usePlayerStore.ts | 4 ++-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 230cfa8..ffd456c 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -42,7 +42,7 @@ export default async function RootLayout({ {children} - + ); diff --git a/src/components/media/GlobalPlayer.tsx b/src/components/media/GlobalPlayer.tsx index 91f33b1..5c90d7f 100644 --- a/src/components/media/GlobalPlayer.tsx +++ b/src/components/media/GlobalPlayer.tsx @@ -7,10 +7,10 @@ import { StreamOverlays } from './StreamOverlays'; import videojs from 'video.js'; import 'video.js/dist/video-js.css'; -export const GlobalPlayer = () => { +export const GlobalPlayer = ({ initialConfig }: { initialConfig?: any }) => { const { - audioUrl, isAudioPlaying, audioVolume, toggleAudio, setAudioVolume, - isVideoActive, videoUrl, videoType, setVideoActive + audioUrl, isAudioPlaying, audioVolume, toggleAudio, setAudioUrl, setAudioVolume, + isVideoActive, videoUrl, videoType, setVideoActive, setVideoUrl, setVideoType } = usePlayerStore(); const audioRef = useRef(null); @@ -19,6 +19,21 @@ export const GlobalPlayer = () => { const [isMuted, setIsMuted] = useState(false); const [lastVolume, setLastVolume] = useState(audioVolume); const [isExpanded, setIsExpanded] = useState(false); + const [hasHydrated, setHasHydrated] = useState(false); + + // Sync from Layout Config on First Load + useEffect(() => { + if (initialConfig) { + if (initialConfig.radio_url && audioUrl === '') { + setAudioUrl(initialConfig.radio_url); + } + if (initialConfig.tv_url && videoUrl === '') { + setVideoUrl(initialConfig.tv_url); + setVideoType(initialConfig.tv_url.includes('youtube.com') || initialConfig.tv_url.includes('youtu.be') ? 'youtube' : 'm3u8'); + } + } + setHasHydrated(true); + }, [initialConfig, setAudioUrl, setVideoUrl, setVideoType]); // Sync Audio State useEffect(() => { @@ -130,7 +145,7 @@ export const GlobalPlayer = () => {
{/* ESTADO COLAPSADO */} - {!isExpanded && (audioUrl || videoUrl) && ( + {!isExpanded && (audioUrl !== '' || videoUrl !== '') && (