【发布时间】:2019-01-02 07:12:13
【问题描述】:
我使用react-native-image-picker 库进行视频录制和react-native-video 播放视频,其中onLoad 回调函数中的视频持续时间已给出,但我如何在我的代码中使用它,谁能指导我?我在函数中写了durationLimit,但它不起作用。如何录制持续时间为 30 秒的视频?我试过this
也失败了。
我的代码
import ImagePicker from 'react-native-image-picker';
import Video from 'react-native-video';
constructor(props){
super(props);
this.state = {
video: '',
isVideo: true
};
};
_handleVideoUpload = () => {
const options = {
mediaType: 'video',
videoQuality: 'medium',
durationLimit: 30000,
thumbnail: true,
allowsEditing: true,
};
ImagePicker.launchCamera(options, (response) => {
if (response.didCancel) {
// console.warn('User cancelled video picker');
return true;
} else if (response.error) {
// console.warn('ImagePicker Error: ', response.error);
} else if (response.customButton) {
console.warn('User tapped custom button: ', response.customButton);
} else {
this.setState({video: response.uri});
}
});
}
render() {
return(
<View>
{
this.state.video != '' ?
<View>
<Video
ref={ref => this._video = ref}
source={{ uri: this.state.video }}
resizeMode={'cover'}
repeat={true}
paused = {true}
onLoad={() => { this._video.seek(2);}}
/>
</View>
:
<TouchableOpacity
onPress={() => this._handleVideoUpload()}
>
<Text>Upload Video</Text>
</TouchableOpacity>
}
</View>
);}
提前谢谢你。
【问题讨论】:
-
嘿@Riddhi,如果您找到任何解决方案,请在此处提供,以便我们也可以以这种方式编码。
-
很抱歉我还没有找到任何解决方案@Purvik Rana 如果我愿意的话,我一定会在这里发帖。
标签: reactjs react-native react-native-video react-native-image-picker