3
votes

I select images perfectly but I cannot select video, what I need to do?

import ImagePicker from 'react-native-image-picker';

openImagePicker(){
  const options = {
    title:'select an option',

    storageOptions:{
      skipBackup:true,
      path:'images'
    }
  }
  ImagePicker.showImagePicker(options,(response) => {
    if(response.didCancel){
      console.log('user cancelled');
    }else if (response.error) {
      console.log('ERROR'+response.error);

    }else if (response.customButton) {
      console.log('user tapped'+response.customButton);
    }else {
      this.setState({
        imagePath: response.uri,
        imageHeight: response.height,
        imageWidth: response.width
      })
    }


  })

  }
3

3 Answers

7
votes

Try to add mediaType on options.

const options = {
      title: 'Video Picker', 
      mediaType: 'video', 
      storageOptions:{
        skipBackup:true,
        path:'images'
      }
};
0
votes

add (mediaType: 'video') only allow you to select videos and that is true since I wish to be able to select images simultaneously

0
votes

for your comment if you want to use both Video and Image file format than use change your mediaType as

const options = {
      title: 'Video Picker', 
      mediaType: 'image/video', 
      ..
};

OR

const options = {
      title: 'Video Picker', 
      mediaType: 'any', 
      ..
};