viro
viro copied to clipboard
Urgent:::Record Video:Error Code-0 :: Getting Error code 0 on stopVideoRecording() for the first time when we open the app
Requirements:
Environment
Please provide the following information about your environment:
- Development OS: Mac
- Device OS & Version: 16.6
- Version: ViroReact version: "^2.20.2" and React Native version: "0.65.1"
- Device(s): Any
Description
Getting ErrorCode:0 on stopVideoRecording() for the first time when we open the app. next time onwards working fine
Reproducible Demo
clone the starter-kit and replace the App.js file with the below code. Give required permissions. click on record button. then stop recording after a while. Alert will be shown as attached.
https://github.com/ViroCommunity/viro/assets/101793956/a4281a7a-75aa-4a8e-92aa-91e41dfb1fea
`import React from "react"; import { Alert, Text, TouchableOpacity, View } from "react-native"; import { ViroARSceneNavigator, ViroARScene } from "@viro-community/react-viro"; import styles from "./AppStyles";
class App extends React.Component { constructor(props) { super(props); this.state = { isRecording: false, cameraTransformInfo: [], fileName: "", }; this.ARSceneNav = null; }
onCameraTransformUpdate = (pos) => { if (this.state.isRecording) { this.setState((prevState) => ({ cameraTransformInfo: [...prevState.cameraTransformInfo, pos.position], })); } };
InitialARScene = () => { return ( <ViroARScene onCameraTransformUpdate={(pos) => { this.onCameraTransformUpdate(pos); }} /> ); };
recordError = (e) => { Alert.alert("Try Again", "Failed to start recording, try again!"); console.error("recordError", e); this.setState((prevState) => ({ isRecording: !prevState.isRecording, })); };
handleRecord = async () => {
const { isRecording } = this.state;
const fileName = ${new Date().getTime()}
;
console.log("this.ARSceneNav::::", this.ARSceneNav);
if (this.ARSceneNav?.arSceneNavigator?.startVideoRecording) {
if (!isRecording) {
this.setState(
{ cameraTransformInfo: [], fileName, isRecording: true },
() => {
this.ARSceneNav.arSceneNavigator.startVideoRecording(
fileName,
true,
this.recordError
);
}
);
console.log("recording startd!");
} else {
const stop =
await this.ARSceneNav.arSceneNavigator.stopVideoRecording();
if (stop.success) {
Alert.alert("Video Saved", Video is save to ${stop.url}
);
} else {
Alert.alert(
"Failed to save video",
Failed with errorCode: ${stop.errorCode}
);
}
this.setState({ isRecording: false });
console.log("recording end", stop, path, stop.url);
}
}
};
render() { const { isRecording } = this.state; return ( <View style={{ flex: 1 }}> <ViroARSceneNavigator ref={(nav) => (this.ARSceneNav = nav)} initialScene={{ scene: this.InitialARScene }} autofocus={true} /> <TouchableOpacity style={styles.recordButton} onPress={this.handleRecord} > <Text style={styles.recordText}> {isRecording ? "Stop" : "Record"} </Text> </TouchableOpacity> </View> ); } }
export default App; `
same issue, random errors code 0. any idea how to fix it?
same issue to me
_stopVideoRecording() returns bellow.
{"errorCode": 0, "success": false}