【问题标题】:How can I select a video from the library with REACT-NATIVE-IMAGE-PICKER?如何使用 REACT-NATIVE-IMAGE-PICKER 从库中选择视频?
【发布时间】:2017-08-25 04:45:25
【问题描述】:

我完美地选择了图像,但我无法选择视频, 我需要做什么?

从“react-native-image-picker”导入 ImagePicker;

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
      })
    }


  })

  }

【问题讨论】:

    标签: react-native


    【解决方案1】:

    尝试在options 上添加mediaType

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

    【讨论】:

    • 感谢您的回答,它对我有用。您能否提及我应该为 Photo 和 Video 选项在 mediaType 中传递什么
    【解决方案2】:

    add (mediaType: 'video') 只允许您选择视频,这是真的,因为我希望能够同时选择图像

    【讨论】:

      【解决方案3】:

      如果您想同时使用 Video 和 Image 文件格式而不是使用将 mediaType 更改为,请发表评论

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

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

      【讨论】:

      • 媒体类型:'混合'
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-16
      • 2021-10-20
      • 2021-09-28
      相关资源
      最近更新 更多