From 4ad6f374490f6c4a1fcc123906dcd34b38baae6a Mon Sep 17 00:00:00 2001 From: tapframe Date: Tue, 8 Jul 2025 15:42:56 +0530 Subject: [PATCH] Refactor ContinueWatchingSection and AndroidVideoPlayer for improved UI and performance, including layout adjustments and more frequent time updates for subtitle synchronization. --- src/components/home/ContinueWatchingSection.tsx | 4 ++-- src/components/player/AndroidVideoPlayer.tsx | 8 ++++---- .../player/subtitles/CustomSubtitles.tsx | 15 ++++++++------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/components/home/ContinueWatchingSection.tsx b/src/components/home/ContinueWatchingSection.tsx index 599d125c..0509b059 100644 --- a/src/components/home/ContinueWatchingSection.tsx +++ b/src/components/home/ContinueWatchingSection.tsx @@ -556,9 +556,9 @@ const ContinueWatchingSection = React.forwardRef((props, re {item.name} {isUpNext && ( - + Up Next - + )} ); diff --git a/src/components/player/AndroidVideoPlayer.tsx b/src/components/player/AndroidVideoPlayer.tsx index 68fd412e..e95fafb8 100644 --- a/src/components/player/AndroidVideoPlayer.tsx +++ b/src/components/player/AndroidVideoPlayer.tsx @@ -502,13 +502,13 @@ const AndroidVideoPlayer: React.FC = () => { const currentTimeInSeconds = data.currentTime; - // Only update if there's a significant change to avoid unnecessary updates - if (Math.abs(currentTimeInSeconds - currentTime) > 0.5) { + // Update time more frequently for subtitle synchronization (0.1s threshold) + if (Math.abs(currentTimeInSeconds - currentTime) > 0.1) { safeSetState(() => setCurrentTime(currentTimeInSeconds)); const progressPercent = duration > 0 ? currentTimeInSeconds / duration : 0; Animated.timing(progressAnim, { toValue: progressPercent, - duration: 250, + duration: 100, useNativeDriver: false, }).start(); const bufferedTime = data.playableDuration || currentTimeInSeconds; @@ -1150,7 +1150,7 @@ const AndroidVideoPlayer: React.FC = () => { playWhenInactive={false} ignoreSilentSwitch="ignore" mixWithOthers="inherit" - progressUpdateInterval={1000} + progressUpdateInterval={250} /> diff --git a/src/components/player/subtitles/CustomSubtitles.tsx b/src/components/player/subtitles/CustomSubtitles.tsx index ea8df40a..dc0c2394 100644 --- a/src/components/player/subtitles/CustomSubtitles.tsx +++ b/src/components/player/subtitles/CustomSubtitles.tsx @@ -20,16 +20,17 @@ export const CustomSubtitles: React.FC = ({ const inverseScale = 1 / zoomScale; return ( - + {currentSubtitle}