From 80d84b3e17701fbdfbaa2bc58cd49e0cbc82f6c9 Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Mon, 12 May 2025 02:25:24 +0000 Subject: [PATCH] Revamp TV Studio page and add live stream preview The TV Studio page now features a new list design, profile deletion, and updated profile creation (uses 'title', create-only). A live video preview has been added to the Live tab for active streams. Also includes fixes for stream health updates and timed thumbnail loading. --- .../components/StreamPreview/index.jsx | 44 +++++++ .../pages/studio/tv/[profile_id]/header.jsx | 6 +- .../pages/studio/tv/[profile_id]/index.jsx | 4 + .../pages/studio/tv/[profile_id]/index.less | 4 +- .../tv/[profile_id]/tabs/Live/index.jsx | 14 ++- .../tv/[profile_id]/tabs/Live/index.less | 13 ++- .../tv/components/ProfileCreator/index.jsx | 45 ++++---- .../tv/components/ProfileItem/index.jsx | 56 +++++++++ .../tv/components/ProfileItem/index.less | 107 ++++++++++++++++++ packages/app/src/pages/studio/tv/index.jsx | 72 ++++++++---- packages/app/src/pages/studio/tv/index.less | 70 ++++++++---- 11 files changed, 356 insertions(+), 79 deletions(-) create mode 100644 packages/app/src/pages/studio/tv/[profile_id]/components/StreamPreview/index.jsx create mode 100644 packages/app/src/pages/studio/tv/components/ProfileItem/index.jsx create mode 100644 packages/app/src/pages/studio/tv/components/ProfileItem/index.less diff --git a/packages/app/src/pages/studio/tv/[profile_id]/components/StreamPreview/index.jsx b/packages/app/src/pages/studio/tv/[profile_id]/components/StreamPreview/index.jsx new file mode 100644 index 00000000..a90bcb94 --- /dev/null +++ b/packages/app/src/pages/studio/tv/[profile_id]/components/StreamPreview/index.jsx @@ -0,0 +1,44 @@ +import React from "react" +import Hls from "hls.js" + +const StreamPreview = ({ profile }) => { + const videoRef = React.useRef(null) + const hlsInstance = React.useRef(null) + + React.useEffect(() => { + hlsInstance.current = new Hls({ + maxLiveSyncPlaybackRate: 1.5, + strategy: "bandwidth", + autoplay: true, + }) + + hlsInstance.current.attachMedia(videoRef.current) + + hlsInstance.current.on(Hls.Events.MEDIA_ATTACHED, () => { + hlsInstance.current.loadSource(profile.sources.hls) + }) + + videoRef.current.addEventListener("play", () => { + console.log("[HLS] Syncing to last position") + videoRef.current.currentTime = hlsInstance.current.liveSyncPosition + }) + + videoRef.current.play() + + return () => { + hlsInstance.current.destroy() + } + }, []) + + return ( +