From 35abf985a92ecb023ee6dbc559b1ff0abf8e9cf1 Mon Sep 17 00:00:00 2001 From: AdityasahuX07 Date: Wed, 17 Dec 2025 13:27:07 +0530 Subject: [PATCH] Modern UI for dynamic volume and brightness overlays and fix brightness control not work on Android Added dynamic volume and brightness icons with overlays for user feedback. Updated gesture handling for improved interaction. --- src/components/player/AndroidVideoPlayer.tsx | 334 +++++++------------ 1 file changed, 122 insertions(+), 212 deletions(-) diff --git a/src/components/player/AndroidVideoPlayer.tsx b/src/components/player/AndroidVideoPlayer.tsx index 2b7ef7e..b46b895 100644 --- a/src/components/player/AndroidVideoPlayer.tsx +++ b/src/components/player/AndroidVideoPlayer.tsx @@ -133,6 +133,20 @@ const AndroidVideoPlayer: React.FC = () => { } as any; }; + // Helper to get dynamic volume icon + const getVolumeIcon = (value: number) => { + if (value === 0) return 'volume-off'; + if (value < 0.3) return 'volume-mute'; + if (value < 0.6) return 'volume-down'; + return 'volume-up'; + }; + + // Helper to get dynamic brightness icon + const getBrightnessIcon = (value: number) => { + if (value < 0.3) return 'brightness-low'; + if (value < 0.7) return 'brightness-medium'; + return 'brightness-high'; + }; // Get appropriate headers based on stream type const getStreamHeaders = () => { @@ -2559,7 +2573,7 @@ const AndroidVideoPlayer: React.FC = () => { logger.log('[AndroidVideoPlayer] Fetching streams for next episode:', nextEpisodeId); - // Import stremio service + // Import stremio service const stremioService = require('../../services/stremioService').default; let bestStream: any = null; @@ -3125,7 +3139,7 @@ const AndroidVideoPlayer: React.FC = () => { } ]} > - {/* Left side gesture handler - tap + long press (brightness gesture disabled) */} + {/* Left side gesture handler - brightness + tap + long press (Android and iOS) */} { shouldCancelWhenOutside={false} simultaneousHandlers={[]} > - - - + + + + {/* Combined gesture handler for right side - volume + tap + long press */} @@ -3398,8 +3421,57 @@ const AndroidVideoPlayer: React.FC = () => { buffered={buffered} formatTime={formatTime} playerBackend={useVLC ? 'VLC' : 'ExoPlayer'} + nextLoadingTitle={nextLoadingTitle} + controlsFixedOffset={Math.min(Dimensions.get('window').width, Dimensions.get('window').height) >= 768 ? 120 : 100} /> + {/* Combined Volume & Brightness Gesture Indicator - NEW PILL STYLE (No Bar) */} + {(gestureControls.showVolumeOverlay || gestureControls.showBrightnessOverlay) && ( + + {/* Dynamic Icon */} + + + + + {/* Text Label: Shows "Muted" or percentage */} + + {/* Conditional Text Content Logic */} + {gestureControls.showVolumeOverlay && volume === 0 + ? "Muted" // Display "Muted" when volume is 0 + : `${Math.round((gestureControls.showVolumeOverlay ? volume : brightness) * 100)}%` // Display percentage otherwise + } + + + )} + {showPauseOverlay && ( { controlsFixedOffset={Math.min(Dimensions.get('window').width, Dimensions.get('window').height) >= 768 ? 120 : 100} /> - {/* Volume Overlay */} - {gestureControls.showVolumeOverlay && ( - - - - - {/* Horizontal Dotted Progress Bar */} - - {/* Dotted background */} - - {Array.from({ length: 16 }, (_, i) => ( - - ))} - - - {/* Progress fill */} - - - - - {Math.round(volume * 100)}% - - - - )} - - {/* Brightness Overlay */} - {gestureControls.showBrightnessOverlay && ( - - - - - {/* Horizontal Dotted Progress Bar */} - - {/* Dotted background */} - - {Array.from({ length: 16 }, (_, i) => ( - - ))} - - - {/* Progress fill */} - - - - - {Math.round(brightness * 100)}% - - - - )} - {/* Speed Activated Overlay */} {showSpeedActivatedOverlay && ( { fontWeight: '600', letterSpacing: 0.5, }}> - {holdToSpeedValue}x Speed Activated + {holdToSpeedValue}x Speed @@ -4175,4 +4053,36 @@ const AndroidVideoPlayer: React.FC = () => { ); }; -export default AndroidVideoPlayer; \ No newline at end of file +// New styles for the gesture indicator +const localStyles = StyleSheet.create({ + gestureIndicatorContainer: { + position: 'absolute', + top: '4%', // Adjust this for vertical position + alignSelf: 'center', // Adjust this for horizontal position + flexDirection: 'row', + alignItems: 'center', + backgroundColor: 'rgba(25, 25, 25)', // Dark pill background + borderRadius: 70, + paddingHorizontal: 15, + paddingVertical: 15, + zIndex: 2000, // Very high z-index to ensure visibility + minWidth: 120, // Adjusted min width since bar is removed + }, + iconWrapper: { + borderRadius: 50, // Makes it a perfect circle (set to a high number) + width: 40, // Define the diameter of the circle + height: 40, // Define the diameter of the circle + justifyContent: 'center', + alignItems: 'center', + marginRight: 12, // Margin to separate icon circle from percentage text + }, + gestureText: { + color: '#FFFFFF', + fontSize: 18, + fontWeight: 'normal', + minWidth: 35, + textAlign: 'right', + }, +}); + +export default AndroidVideoPlayer;