cast modal fix

This commit is contained in:
tapframe 2025-09-18 14:14:30 +05:30
parent e98012862c
commit 73b56bad4b
2 changed files with 26 additions and 2 deletions

View file

@ -162,6 +162,7 @@ const VideoPlayer: React.FC = () => {
const seekDebounceTimer = useRef<NodeJS.Timeout | null>(null);
const pendingSeekValue = useRef<number | null>(null);
const lastSeekTime = useRef<number>(0);
const wasPlayingBeforeDragRef = useRef<boolean>(false);
const [isVideoLoaded, setIsVideoLoaded] = useState(false);
const [videoAspectRatio, setVideoAspectRatio] = useState<number | null>(null);
const [is16by9Content, setIs16by9Content] = useState(false);
@ -843,6 +844,8 @@ const VideoPlayer: React.FC = () => {
const handleSlidingStart = () => {
setIsDragging(true);
// Remember if we were playing before the user started dragging
wasPlayingBeforeDragRef.current = !paused;
// Keep controls visible while dragging and cancel any hide timeout
if (!showControls) setShowControls(true);
if (controlsTimeout.current) {
@ -856,6 +859,14 @@ const VideoPlayer: React.FC = () => {
if (duration > 0) {
const seekTime = Math.min(value, duration - END_EPSILON);
seekToTime(seekTime);
// If the video was playing before the drag, ensure we remain in playing state after the seek
if (wasPlayingBeforeDragRef.current) {
setTimeout(() => {
if (isMounted.current) {
setPaused(false);
}
}, 350);
}
pendingSeekValue.current = null;
}
// Restart auto-hide timer after interaction finishes
@ -905,6 +916,14 @@ const VideoPlayer: React.FC = () => {
completeOpeningAnimation();
}
// If time is advancing right after seek and we previously intended to play,
// ensure paused state is false to keep UI in sync
if (wasPlayingBeforeDragRef.current && paused && !isDragging) {
setPaused(false);
// Reset the intent once corrected
wasPlayingBeforeDragRef.current = false;
}
// Periodic check for disabled audio track (every 3 seconds, max 3 attempts)
const now = Date.now();
if (now - lastAudioTrackCheck > 3000 && !paused && duration > 0 && audioTrackFallbackAttempts < 3) {

View file

@ -8,8 +8,8 @@ import {
Dimensions,
Platform,
Alert,
FlatList,
} from 'react-native';
import { FlashList } from '@shopify/flash-list';
import { MaterialIcons } from '@expo/vector-icons';
import { Image } from 'expo-image';
import Animated, {
@ -352,6 +352,7 @@ const CastMoviesScreen: React.FC = () => {
style={{
width: posterWidth,
marginBottom: 20,
marginRight: (index + 1) % numColumns === 0 ? 0 : 12,
}}
>
<TouchableOpacity
@ -704,7 +705,7 @@ const CastMoviesScreen: React.FC = () => {
</Text>
</View>
) : (
<FlashList
<FlatList
data={displayedMovies}
renderItem={renderMovieItem}
keyExtractor={(item) => `${item.media_type}-${item.id}`}
@ -722,6 +723,10 @@ const CastMoviesScreen: React.FC = () => {
showsVerticalScrollIndicator={false}
onEndReached={handleLoadMore}
onEndReachedThreshold={0.8}
removeClippedSubviews={false}
initialNumToRender={30}
maxToRenderPerBatch={20}
windowSize={7}
ListFooterComponent={
displayLimit < filteredAndSortedMovies.length ? (
<View style={{