|
|
@ -1,77 +1,74 @@ |
|
|
|
import React, { useState, useEffect } from "react"; |
|
|
|
import React, {useState, useEffect} from 'react'; |
|
|
|
import { |
|
|
|
import { |
|
|
|
View, |
|
|
|
View, |
|
|
|
StyleSheet, |
|
|
|
StyleSheet, |
|
|
|
Dimensions, |
|
|
|
Dimensions, |
|
|
|
ScrollView, |
|
|
|
ScrollView, |
|
|
|
SafeAreaView, |
|
|
|
|
|
|
|
StatusBar, |
|
|
|
StatusBar, |
|
|
|
LayoutAnimation, |
|
|
|
LayoutAnimation, |
|
|
|
Text, |
|
|
|
Text, |
|
|
|
Platform, |
|
|
|
Platform, |
|
|
|
} from "react-native"; |
|
|
|
} from 'react-native'; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context'; |
|
|
|
import { publicApi } from "../../redux/actions"; |
|
|
|
import {connect} from 'react-redux'; |
|
|
|
import { Video } from "expo-av"; |
|
|
|
import Video from 'react-native-video'; |
|
|
|
import * as ScreenOrientation from "expo-screen-orientation"; |
|
|
|
|
|
|
|
|
|
|
|
// import * as ScreenOrientation from 'expo-screen-orientation';
|
|
|
|
|
|
|
|
|
|
|
|
//components
|
|
|
|
//components
|
|
|
|
import Navbar from "../../components/Navbar"; |
|
|
|
import Navbar from '../../components/Navbar'; |
|
|
|
import Drawer from "../../components/Drawer"; |
|
|
|
import Drawer from '../../components/Drawer'; |
|
|
|
import Season from "./components/Season"; |
|
|
|
import Season from './components/Season'; |
|
|
|
import Divider from "../../components/Divider"; |
|
|
|
import Divider from '../../components/Divider'; |
|
|
|
|
|
|
|
|
|
|
|
//style
|
|
|
|
//style
|
|
|
|
import tw from "tailwind-rn"; |
|
|
|
import tw from 'tailwind-rn'; |
|
|
|
import fontSize from "../../constants/fontSize"; |
|
|
|
import fontSize from '../../constants/fontSize'; |
|
|
|
import Colors from "../../constants/Colors"; |
|
|
|
import Colors from '../../constants/Colors'; |
|
|
|
|
|
|
|
|
|
|
|
//assets
|
|
|
|
//assets
|
|
|
|
import posterImage from "../../assets/images/poster.png"; |
|
|
|
import posterImage from '../../assets/images/poster.png'; |
|
|
|
|
|
|
|
|
|
|
|
const ios = Platform.OS === "ios"; |
|
|
|
const ios = Platform.OS === 'ios'; |
|
|
|
|
|
|
|
|
|
|
|
function VideoDisplay({ route, mobile, theme }) { |
|
|
|
function VideoDisplay({route, mobile, theme}) { |
|
|
|
|
|
|
|
const insets = useSafeAreaInsets(); |
|
|
|
const video = React.useRef(null); |
|
|
|
const video = React.useRef(null); |
|
|
|
const [width, setWidth] = useState(Dimensions.get("window").width); |
|
|
|
const [width, setWidth] = useState(Dimensions.get('window').width); |
|
|
|
const [position, setPosition] = useState("100%"); |
|
|
|
const [position, setPosition] = useState('100%'); |
|
|
|
|
|
|
|
|
|
|
|
const setBoxPosition = () => { |
|
|
|
const setBoxPosition = () => { |
|
|
|
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut); |
|
|
|
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut); |
|
|
|
setPosition(position === "100%" ? "0%" : "100%"); |
|
|
|
setPosition(position === '100%' ? '0%' : '100%'); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const onFullscreenUpdate = async ({ fullscreenUpdate }) => { |
|
|
|
// const onFullscreenUpdate = async ({fullscreenUpdate}) => {
|
|
|
|
if (fullscreenUpdate === Video.FULLSCREEN_UPDATE_PLAYER_DID_PRESENT) { |
|
|
|
// if (fullscreenUpdate === Video.FULLSCREEN_UPDATE_PLAYER_DID_PRESENT) {
|
|
|
|
await ScreenOrientation.unlockAsync(); |
|
|
|
// await ScreenOrientation.unlockAsync();
|
|
|
|
} else if ( |
|
|
|
// } else if (
|
|
|
|
fullscreenUpdate === Video.FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS |
|
|
|
// fullscreenUpdate === Video.FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS
|
|
|
|
) { |
|
|
|
// ) {
|
|
|
|
await ScreenOrientation.lockAsync( |
|
|
|
// await ScreenOrientation.lockAsync(
|
|
|
|
ScreenOrientation.OrientationLock.PORTRAIT |
|
|
|
// ScreenOrientation.OrientationLock.PORTRAIT,
|
|
|
|
); |
|
|
|
// );
|
|
|
|
} |
|
|
|
// }
|
|
|
|
}; |
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
React.useEffect(() => { |
|
|
|
React.useEffect(() => { |
|
|
|
video.current.replayAsync(); |
|
|
|
// video.current.replayAsync();
|
|
|
|
video.current.playAsync(); |
|
|
|
// video.current.playAsync();
|
|
|
|
}, [route]); |
|
|
|
}, [route]); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<SafeAreaView |
|
|
|
<SafeAreaView |
|
|
|
style={{ |
|
|
|
style={{flex: 1, paddingTop: insets.top, paddingBottom: insets.bottom}}> |
|
|
|
paddingTop: !ios ? StatusBar.currentHeight : 0, |
|
|
|
|
|
|
|
position: "relative", |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Navbar |
|
|
|
<Navbar |
|
|
|
setBoxPosition={setBoxPosition} |
|
|
|
setBoxPosition={setBoxPosition} |
|
|
|
headerOptions={{ |
|
|
|
headerOptions={{ |
|
|
|
logo: false, |
|
|
|
logo: false, |
|
|
|
menu: true, |
|
|
|
menu: true, |
|
|
|
hamburgerMenu: false, |
|
|
|
hamburgerMenu: false, |
|
|
|
title: "", |
|
|
|
title: '', |
|
|
|
bookmark: false, |
|
|
|
bookmark: false, |
|
|
|
qr: false, |
|
|
|
qr: false, |
|
|
|
back: true, |
|
|
|
back: true, |
|
|
@ -81,61 +78,58 @@ function VideoDisplay({ route, mobile, theme }) { |
|
|
|
<ScrollView |
|
|
|
<ScrollView |
|
|
|
contentContainerStyle={styles.contentContainerStyle} |
|
|
|
contentContainerStyle={styles.contentContainerStyle} |
|
|
|
style={styles.container} |
|
|
|
style={styles.container} |
|
|
|
onLayout={() => setWidth(Dimensions.get("window").width)} |
|
|
|
onLayout={() => setWidth(Dimensions.get('window').width)}> |
|
|
|
> |
|
|
|
{!mobile ? <View style={tw('mt-5')}></View> : null} |
|
|
|
{!mobile ? <View style={tw("mt-5")}></View> : null} |
|
|
|
<View style={tw('flex')}> |
|
|
|
<View style={tw("flex ")}> |
|
|
|
|
|
|
|
<Video |
|
|
|
<Video |
|
|
|
|
|
|
|
source={{ |
|
|
|
|
|
|
|
uri: `https://dnvn.ir/api/v1/file/${route.params.unit?.fileIds}`, |
|
|
|
|
|
|
|
}} // Can be a URL or a local file.
|
|
|
|
ref={video} |
|
|
|
ref={video} |
|
|
|
|
|
|
|
resizeMode="cover" |
|
|
|
|
|
|
|
fullscreen={true} |
|
|
|
|
|
|
|
fullscreenOrientation='landscape' |
|
|
|
|
|
|
|
// Store reference
|
|
|
|
|
|
|
|
onBuffer={() => {}} // Callback when remote video is buffering
|
|
|
|
|
|
|
|
onError={() => {}} // Callback when video cannot be loaded
|
|
|
|
style={{ |
|
|
|
style={{ |
|
|
|
width: "100%", |
|
|
|
width: '100%', |
|
|
|
height: (width * 3) / 4.57 - 16, |
|
|
|
height: (width * 3) / 4.57 - 16, |
|
|
|
borderWidth: 1, |
|
|
|
borderWidth: 1, |
|
|
|
borderColor: |
|
|
|
borderColor: |
|
|
|
theme === "light" |
|
|
|
theme === 'light' |
|
|
|
? Colors.theme1.gray2077 + "66" |
|
|
|
? Colors.theme1.gray2077 + '66' |
|
|
|
: Colors.theme1.white + "55", |
|
|
|
: Colors.theme1.white + '55', |
|
|
|
shadowColor: "#00000055", |
|
|
|
shadowColor: '#00000055', |
|
|
|
shadowOffset: { width: 0, height: 1 }, |
|
|
|
shadowOffset: {width: 0, height: 1}, |
|
|
|
shadowOpacity: 0.8, |
|
|
|
shadowOpacity: 0.8, |
|
|
|
shadowRadius: 2, |
|
|
|
shadowRadius: 2, |
|
|
|
elevation: 5, |
|
|
|
elevation: 5, |
|
|
|
zIndex : 100, |
|
|
|
zIndex: 100, |
|
|
|
}} |
|
|
|
|
|
|
|
source={{ |
|
|
|
|
|
|
|
uri: `https://dnvn.ir/api/v1/file/${route.params.unit?.fileIds}`, |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
useNativeControls |
|
|
|
|
|
|
|
resizeMode="cover" |
|
|
|
|
|
|
|
onFullscreenUpdate={onFullscreenUpdate} |
|
|
|
|
|
|
|
usePoster={true} |
|
|
|
|
|
|
|
posterSource={posterImage} |
|
|
|
|
|
|
|
posterStyle={{ |
|
|
|
|
|
|
|
width: "100%", |
|
|
|
|
|
|
|
height: "100%", |
|
|
|
|
|
|
|
}} |
|
|
|
}} |
|
|
|
|
|
|
|
controls |
|
|
|
|
|
|
|
// poster={{ uri : posterImage }}
|
|
|
|
/> |
|
|
|
/> |
|
|
|
<Text |
|
|
|
<Text |
|
|
|
style={{ |
|
|
|
style={{ |
|
|
|
fontSize: fontSize.xl, |
|
|
|
fontSize: fontSize.xl, |
|
|
|
fontFamily: "Medium", |
|
|
|
fontFamily: 'Medium', |
|
|
|
marginTop: mobile ? 20 : 12, |
|
|
|
marginTop: mobile ? 20 : 12, |
|
|
|
color: |
|
|
|
color: |
|
|
|
theme === "light" ? Colors.theme1.gray20 : Colors.theme1.white, |
|
|
|
theme === 'light' ? Colors.theme1.gray20 : Colors.theme1.white, |
|
|
|
textAlign: "right", |
|
|
|
textAlign: 'right', |
|
|
|
}} |
|
|
|
}}> |
|
|
|
> |
|
|
|
|
|
|
|
{route.params.unit?.name} |
|
|
|
{route.params.unit?.name} |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
<View |
|
|
|
<View |
|
|
|
style={[ |
|
|
|
style={[ |
|
|
|
tw("flex flex-1 justify-between"), |
|
|
|
tw('flex flex-1 justify-between'), |
|
|
|
{ |
|
|
|
{ |
|
|
|
paddingRight: 10, |
|
|
|
paddingRight: 10, |
|
|
|
}, |
|
|
|
}, |
|
|
|
]} |
|
|
|
]}> |
|
|
|
> |
|
|
|
<Divider type={'vertical'} /> |
|
|
|
<Divider type={"vertical"} /> |
|
|
|
|
|
|
|
</View> |
|
|
|
</View> |
|
|
|
{route?.params?.videoBuyed ? ( |
|
|
|
{route?.params?.videoBuyed ? ( |
|
|
|
<Season |
|
|
|
<Season |
|
|
@ -161,7 +155,7 @@ const styles = StyleSheet.create({ |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
const mapStateToProps = state => ({ |
|
|
|
grades: state.publicApi.grades, |
|
|
|
grades: state.publicApi.grades, |
|
|
|
mobile: state.publicApi.mobile, |
|
|
|
mobile: state.publicApi.mobile, |
|
|
|
theme: state.publicApi.theme, |
|
|
|
theme: state.publicApi.theme, |
|
|
|