I have function called record and stopRecording in my React Native / Expo app. These help me record videos in my app.
async function record(){ if(camera){ setRecording(true); let recording = await camera.current.recordAsync(); console.log(recording); setVideoUri(recording.uri); const { uri, width, height } = await VideoThumbnails.getThumbnailAsync(recording.uri, { time: 0 }); setThumbnailUri(uri); }}async function stopRecording(){ if(camera){ setRecording(false); camera.current.stopRecording(); }}
On iOS, this works perfectly. And the console.log(recording) line produces the following AFTER I stop recording:
Object {"uri": "file:///var/mobile/Containers/Data/Application/AD28FEB3-916D-4804-B609-42336E916F75/Library/Caches/ExponentExperienceData/%2540vaibhavverma9%252Freeltalk/Camera/69064C71-02D0-472C-B3A0-CFF2F87D0B9E.mov",}
On Android, on the other hand, I get a stop failed error immediately after starting to record. Note, I don't even call the stopRecording button. It produces this:
Object {"uri": "file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540vaibhavverma9%252Freeltalk/Camera/f1ac8f11-7eb9-4960-ba90-d63e14c434a1.mp4",}
But I get the following error, because since there's no video recorded, the thumbnail is not set.
0, [Error: Could not generate thumbnail. setDataSource failed: status = 0x80000000]- node_modules/expo/build/environment/muteWarnings.fx.js:18:23 in warn- node_modules/@sentry/utils/dist/instrument.js:111:42 in <anonymous>- node_modules/@sentry/react-native/dist/js/integrations/reactnativeerrorhandlers.js:36:33 in tracking.enable$argument_0.onUnhandled- node_modules/promise/setimmediate/rejection-tracking.js:72:10 in onUnhandled* [native code]:null in onUnhandled- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:146:14 in _callTimer- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:399:17 in callTimers- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:436:47 in __callFunction- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:111:26 in __guard$argument_0- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:10 in __guard- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:110:17 in __guard$argument_0* [native code]:null in callFunctionReturnFlushedQueue
Does anyone know why this recordAsync() function works in iOS but not in Android? Is there something I must do in order to get the function working on Android as well?