viro icon indicating copy to clipboard operation
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

Open anusha-fission opened this issue 11 months ago • 3 comments

Requirements:

Environment

Please provide the following information about your environment:

  1. Development OS: Mac
  2. Device OS & Version: 16.6
  3. Version: ViroReact version: "^2.20.2" and React Native version: "0.65.1"
  4. 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 Image_20230824_153318_244

`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; `

anusha-fission avatar Aug 24 '23 10:08 anusha-fission

same issue, random errors code 0. any idea how to fix it?

gwendall avatar Nov 28 '23 18:11 gwendall

same issue to me

illlama avatar Jan 29 '24 05:01 illlama

_stopVideoRecording() returns bellow.

{"errorCode": 0, "success": false}

illlama avatar Mar 04 '24 12:03 illlama