-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample3.js
104 lines (97 loc) · 2.35 KB
/
example3.js
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
95
96
97
98
99
100
101
102
103
104
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from "react";
import { Alert, StyleSheet, Text, View, Dimensions, TouchableOpacity } from "react-native";
import Video from "react-native-video";
const { height, width } = Dimensions.get("screen");
type Props = {};
type State = {
showLocal: boolean
};
function Button({ text, onPress }: { text: string, onPress: () => void }) {
return (
<TouchableOpacity
onPress={onPress}
style={styles.button}
>
<Text style={{color: 'white'}}>{text}</Text>
</TouchableOpacity>
)
}
export default class App extends Component<Props, State> {
state = {
showLocal: false
}
render() {
return (
<View style={styles.container}>
<Video
source={
this.state.showLocal ?
require('../basic/broadchurch.mp4') :
{
uri: "https://rawgit.com/mediaelement/mediaelement-files/master/big_buck_bunny.mp4"
}
}
ref={player => {
this.player = player;
}}
onEnd={() => {
this.player.seek(0);
}}
onError={(err) => {
Alert.alert(JSON.stringify(err))
}}
style={{ flex: 1, height, width }}
/>
<View style={styles.absoluteOverlay}>
<Button
onPress={async () => {
let response = await this.player.save();
let uri = response.uri;
console.warn("Download URI", uri);
}}
text="Save"
/>
<Button
onPress={() => {
this.setState(state => ({ showLocal: !state.showLocal }))
}}
text={this.state.showLocal ? "Show Remote" : "Show Local"}
/>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: "#F5FCFF"
},
absoluteOverlay: {
flexDirection: 'row',
position: 'absolute',
top: 0,
width: '100%',
marginTop: 50,
},
button: {
padding: 10,
backgroundColor: '#9B2FAE',
borderRadius: 8,
flex: 1,
alignItems: 'center',
marginHorizontal: 5,
},
welcome: {
fontSize: 20,
textAlign: "center",
margin: 10
}
});