-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVideoplayerDemo.js
43 lines (39 loc) · 1.03 KB
/
VideoplayerDemo.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
import React from 'react';
import { StyleSheet, Button, View, Image, Text } from 'react-native';
import * as VideoThumbnails from 'expo-video-thumbnails';
export default class VideoPlayerDemo extends React.Component {
state = {
image: null,
};
generateThumbnail = async () => {
try {
const { uri } = await VideoThumbnails.getThumbnailAsync(
'http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4',
{
time: 15000,
}
);
this.setState({ image: uri });
} catch (e) {
console.warn(e);
}
};
render() {
const { image } = this.state;
return (
<View style={styles.container}>
<Button onPress={this.generateThumbnail} title="Generate thumbnail" />
{image && <Image source={{ uri: image }} style={{ width: 200, height: 200 }} />}
<Text>{image}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
});