我尝试使用 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>
);
}
这些是我使用的代码。请有人提出修复建议。