@@ -3,29 +3,30 @@ import {
33 CarouselContextProvider ,
44 useAutoCarouselSlideIndex ,
55} from '@strv/react-native-hero-carousel'
6- import { SafeAreaView , StyleSheet , View , Text , Pressable } from 'react-native'
6+ import { SafeAreaView , StyleSheet , View , Text , Pressable , Dimensions , Platform } from 'react-native'
77import { useVideoPlayer , VideoView } from 'expo-video'
88import { LinearGradient } from 'expo-linear-gradient'
99import { useActiveSlideEffect , useIsActiveSlide } from '@/hooks/useActiveSlideEffect'
1010import { useEffect , useRef , useState } from 'react'
1111import { TimerPagination } from './components/TimerPagination'
1212import { useEvent , useEventListener } from 'expo'
1313
14+ const { width, height } = Dimensions . get ( 'window' )
1415// Sample video URLs - these are publicly available videos that work well for testing
1516const videos = [
16- 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4' ,
17- 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4' ,
1817 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4' ,
1918 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4' ,
2019 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerFun.mp4' ,
20+ 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4' ,
21+ 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4' ,
2122]
2223
2324const videoTitles = [
24- 'Big Buck Bunny' ,
25- 'Elephants Dream' ,
2625 'For Bigger Blazes' ,
2726 'For Bigger Escapes' ,
2827 'For Bigger Fun' ,
28+ 'Big Buck Bunny' ,
29+ 'Elephants Dream' ,
2930]
3031
3132const Slide = ( { videoUri, title, index } : { videoUri : string ; title : string ; index : number } ) => {
@@ -58,26 +59,33 @@ const Slide = ({ videoUri, title, index }: { videoUri: string; title: string; in
5859 } , [ isActiveSlide , duration , runAutoScroll ] )
5960
6061 return (
61- < Pressable
62- key = { index }
63- style = { styles . slide }
64- onPress = { ( ) => {
65- if ( isPlaying ) {
66- player . pause ( )
67- intervalRef . current ?. pause ( )
68- } else {
69- player . play ( )
70- intervalRef . current ?. resume ( )
71- }
72- } }
73- >
74- < VideoView player = { player } style = { styles . video } contentFit = "cover" nativeControls = { false } />
75- < LinearGradient colors = { [ 'rgba(0,0,0,0.8)' , 'transparent' ] } style = { styles . topGradient } />
76- < LinearGradient colors = { [ 'transparent' , 'rgba(0,0,0,0.8)' ] } style = { styles . gradient } >
77- < Text style = { styles . title } > { title } </ Text >
78- < Text style = { styles . subtitle } > Swipe to navigate • Tap to play/pause</ Text >
79- </ LinearGradient >
80- </ Pressable >
62+ < View style = { styles . slide } >
63+ < Pressable
64+ key = { index }
65+ style = { styles . slide }
66+ onPress = { ( ) => {
67+ if ( isPlaying ) {
68+ player . pause ( )
69+ intervalRef . current ?. pause ( )
70+ } else {
71+ player . play ( )
72+ intervalRef . current ?. resume ( )
73+ }
74+ } }
75+ >
76+ < VideoView
77+ player = { player }
78+ style = { styles . video }
79+ contentFit = { Platform . OS === 'android' ? 'fill' : 'cover' }
80+ nativeControls = { false }
81+ />
82+ < LinearGradient colors = { [ 'rgba(0,0,0,0.8)' , 'transparent' ] } style = { styles . topGradient } />
83+ < LinearGradient colors = { [ 'transparent' , 'rgba(0,0,0,0.8)' ] } style = { styles . gradient } >
84+ < Text style = { styles . title } > { title } </ Text >
85+ < Text style = { styles . subtitle } > Swipe to navigate • Tap to play/pause</ Text >
86+ </ LinearGradient >
87+ </ Pressable >
88+ </ View >
8189 )
8290}
8391
@@ -110,8 +118,8 @@ const styles = StyleSheet.create({
110118 overflow : 'hidden' ,
111119 } ,
112120 video : {
113- width : '100%' ,
114- height : '100%' ,
121+ width : width ,
122+ height : height ,
115123 } ,
116124 gradient : {
117125 position : 'absolute' ,
0 commit comments