-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJSControlsScreen.tsx
94 lines (82 loc) · 2.62 KB
/
JSControlsScreen.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import React, {useState, useEffect} from 'react';
import {StyleSheet, Text, SafeAreaView} from 'react-native';
import VdoPlayerControls from './VdoPlayerControls';
import {NativeStackScreenProps} from '@react-navigation/native-stack';
import { RootStackParamList } from './type';
type State = {
isFullscreen: boolean;
isInPictureInPictureMode: boolean;
};
export default function JSControlsScreen(props: NativeStackScreenProps<RootStackParamList, 'JSControls'>) {
const [isFullscreen, setIsFullscreen] = useState(false);
const [isInPictureInPictureMode, setIsInPictureInPictureMode] = useState(false);
useEffect(() => {
console.log('JSControlsScreen did mount');
return () => {
console.log('JSControlsScreen will unmount');
}
}, [])
const _onEnterFullscreen = () => {
setIsFullscreen(true)
};
const _onExitFullscreen = () => {
setIsFullscreen(false)
};
const _onPictureInPictureModeChanged = (isInPictureInPictureMode: boolean) => {
setIsInPictureInPictureMode(isInPictureInPictureMode)
};
const embedInfo = props.route.params.embedInfo;
return (
<SafeAreaView style={styles.container}>
<VdoPlayerControls
style={
isFullscreen || isInPictureInPictureMode
? styles.playerFullscreen
: styles.player
}
embedInfo={embedInfo}
showNativeControls={false}
onInitializationSuccess={() => console.log('init success')}
onInitializationFailure={() => console.log('init failure')}
onLoading={(args: any) => console.log('loading')}
onLoaded={(args: any) => console.log('loaded')}
onLoadError={({errorDescription}: any) =>
console.log('load error', errorDescription)
}
onError={({errorDescription}: any) =>
console.log('error', errorDescription)
}
onTracksChanged={(args: any) => console.log('tracks changed')}
onMediaEnded={(args: any) => console.log('ended')}
onEnterFullscreen={_onEnterFullscreen}
onExitFullscreen={_onExitFullscreen}
onPictureInPictureModeChanged={_onPictureInPictureModeChanged}
/>
{!isFullscreen && (
<Text style={styles.description}>
The ui controls for the player are react-native components
</Text>
)}
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
player: {
height: 200,
width: '100%',
},
playerFullscreen: {
height: '100%',
width: '100%',
},
description: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
});