我尝试使用expo-camera捕获视频,一旦录制了视频,因为我们得到了一个视频uri,我用这个uri来显示预览,显示预览时我使用了expo的视频组件-av, 但是视频组件显示空白屏幕。有人可以提出修复建议吗?
const takeVideo = async ()=>{
if(cameraRef)
{
setIsRecording(true);
let res = await cameraRef.recordAsync();
console.log(res);
setVideoUri(res.uri);
setVideoModalVisible(true);
setIsRecording(false);
}
}
const VideoPreview = (props)=>{
return (
<Modal visible={videoModalVisible}>
<View style={{ flex: 1, margin: 50, paddingTop: 20, flexDirection: "column", justifyContent: "flex-start", alignItems: "center", backgroundColor: "white" }}>
<Video
source={{ uri: videoUri }}
rate={1.0}
volume={1.0}
isMuted={false}
resizeMode="cover"
shouldPlay = {false}
isLooping = {false}
useNativeControls
style={{width:width*0.75,height:height*0.5}}
/>
<View style={{ flexDirection: "column" }}>
<Button mode="contained" style={{ margin: 5 }} onPress={() => { sendFile(videoUri,"video"); }}>Send</Button>
<Button mode="contained" style={{ margin: 5 }} onPress={() => { setVideoModalVisible(false) }}>Close</Button>
</View>
</View>
</Modal>
);
}
这些是我使用的代码。请有人提出解决方案。