2017-08-25 90 views
0

我選擇完美的圖像,但我無法選擇視頻, 我需要做什麼?如何使用REACT-NATIVE-IMAGE-PICKER從庫中選擇視頻?

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


    }) 

    } 

回答

0

嘗試在options添加mediaType

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

謝謝,它的工作原理! – Oscar

+0

如何在'View'中顯示選定的視頻? –

相關問題