From 3843ecdd84d4c881020b9358aaf0c1c60acf4bf5 Mon Sep 17 00:00:00 2001 From: kuekhaoyang Date: Mon, 24 Nov 2025 22:15:57 +0800 Subject: [PATCH] feat: Implement intelligent HLS preloading that respects player loading state and browser buffer health. --- components/player/DesktopVideoPlayer.tsx | 2 +- components/player/MobileVideoPlayer.tsx | 5 ++- .../hooks/desktop/useProgressControls.ts | 9 +++- .../hooks/mobile/useMobilePlaybackControls.ts | 10 ++++- .../hooks/mobile/useMobileProgressControls.ts | 5 +-- components/player/hooks/useHLSPreloader.ts | 41 +++++++++++++++++-- lib/hooks/useHistoryDownloader.ts | 5 +++ lib/utils/segmentDownloader.ts | 5 +-- 8 files changed, 64 insertions(+), 18 deletions(-) diff --git a/components/player/DesktopVideoPlayer.tsx b/components/player/DesktopVideoPlayer.tsx index accdc5d..853632f 100644 --- a/components/player/DesktopVideoPlayer.tsx +++ b/components/player/DesktopVideoPlayer.tsx @@ -27,7 +27,7 @@ export function DesktopVideoPlayer({ const { currentTime } = state; // Preload HLS segments - useHLSPreloader({ src, currentTime }); + useHLSPreloader({ src, currentTime, videoRef: refs.videoRef, isLoading: state.isLoading }); const { videoRef, diff --git a/components/player/MobileVideoPlayer.tsx b/components/player/MobileVideoPlayer.tsx index 7098aa7..f6cae96 100644 --- a/components/player/MobileVideoPlayer.tsx +++ b/components/player/MobileVideoPlayer.tsx @@ -31,7 +31,7 @@ export function MobileVideoPlayer({ const { currentTime } = state; // Preload HLS segments - useHLSPreloader({ src, currentTime }); + useHLSPreloader({ src, currentTime, videoRef: refs.videoRef, isLoading: state.isLoading }); const { videoRef, @@ -97,7 +97,7 @@ export function MobileVideoPlayer({ {/* Video Element */}