No Description

App.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import React from 'react';
  2. import { StyleSheet, Text, View, TouchableOpacity } from 'react-native';
  3. import ImagePicker from 'react-native-image-picker';
  4. import RNThumbnail from 'react-native-thumbnail';
  5. export default class App extends React.Component {
  6. constructor(props) {
  7. super(props)
  8. this.state = {
  9. thumbnail: null
  10. }
  11. }
  12. openPicker () {
  13. var options = {
  14. title: 'Select Video',
  15. storageOptions: {
  16. skipBackup: true,
  17. path: 'images'
  18. },
  19. mediaType: 'video'
  20. };
  21. ImagePicker.showImagePicker(options, (response) => {
  22. console.log('Response = ', response);
  23. if (response.didCancel) {
  24. console.log('User cancelled image picker');
  25. }
  26. else if (response.error) {
  27. console.log('ImagePicker Error: ', response.error);
  28. }
  29. else {
  30. console.log(response.uri)
  31. RNThumbnail.get(response.uri).then((result) => {
  32. console.log(result.path); // thumbnail path
  33. })
  34. }
  35. });
  36. }
  37. render() {
  38. return (
  39. <View style={styles.container}>
  40. <TouchableOpacity onPress={this.openPicker}><Text>Click Me</Text></TouchableOpacity>
  41. {this.state.thumbnail ? <Image source={this.state.thumbnail} /> : null}
  42. </View>
  43. );
  44. }
  45. }
  46. const styles = StyleSheet.create({
  47. container: {
  48. flex: 1,
  49. backgroundColor: '#fff',
  50. alignItems: 'center',
  51. justifyContent: 'center',
  52. },
  53. });