-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNativeControlsScreen.tsx
71 lines (63 loc) · 2.1 KB
/
NativeControlsScreen.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
import React, {useEffect} from 'react';
import {StyleSheet, Text, SafeAreaView} from 'react-native';
import {VdoPlayerView} from 'vdocipher-rn-bridge';
import {NativeStackScreenProps} from '@react-navigation/native-stack';
import { RootStackParamList } from './type';
export default function NativeControlsScreen(props: NativeStackScreenProps<RootStackParamList, 'NativeControls'>) {
let _player: any;
useEffect(() => {
console.log('NativeControlsScreen did mount');
return() => {
console.log('NativeControlsScreen will unmount');
}
}, [])
const embedInfo = props.route.params.embedInfo;
return (
<SafeAreaView style={styles.container}>
<VdoPlayerView
ref={(player: any) => (_player = player)}
style={styles.player}
embedInfo={embedInfo}
onInitializationSuccess={() => console.log('init success')}
onInitializationFailure={(error: any) =>
console.log('init failure', error)
}
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')}
onPlaybackSpeedChanged={(speed: any) =>
console.log('speed changed to', speed)
}
onMediaEnded={(args: any) => console.log('ended')}
onEnterFullscreen={() => console.log('onEnterFullscreen')}
onExitFullscreen={() => console.log('onExitFullscreen')}
/>
<Text style={styles.description}>
The ui controls for the player are embedded inside the native view
</Text>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
player: {
height: 'auto',
width: '100%',
resizeMode: 'contain'
},
description: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
});