Prerequisites
- A working React Native quickstart
- A ready
NosmaiCameraView
Recording configuration
startRecording() takes no configuration argument in this React Native API. There is no public JavaScript recording setter for quality, bitrate, FPS, audio enablement, output size, destination, or maximum duration. The native recorder chooses defaults and creates a temporary MP4.
Do not infer file resolution from React view dimensions or assume RTC publishing settings configure local recording. Android can reduce recording size on measured lower-tier devices while keeping preview dimensions intact. For independent encoding or audio mixing, use a native output adapter or the provider's recording facilities; the low-rate JavaScript analysis-frame stream is not a real-time recording transport.
An app-owned duration limit must use the same serialized stop flow as the record button. Verify the output's audio and permissions on each native platform rather than assuming a live-call microphone track is included.
Start recording
await NosmaiCameraSdk.startRecording();
Stop and save
const recording = await NosmaiCameraSdk.stopRecording(); console.log(recording.durationSeconds, recording.hasAudio); await NosmaiCameraSdk.saveVideoToGallery( recording.uri, 'nosmai-video' );
The stop result contains a temporary local MP4 URI, duration, size, MIME type, and whether the finalized file includes audio.
fileSizeBytes is bytes and durationSeconds is seconds. Starting and stopping can reject; a successful start is not a guarantee that finalization will succeed. Gallery saving is a separate operation with its own result and permissions. Copy or export temporary files before the application removes temporary data.
Observe recording progress
const progressSubscription = NosmaiCameraSdk.addRecordingProgressListener(progress => {
console.log('Recording seconds:', progress.durationSeconds);
});
const recordingActive = await NosmaiCameraSdk.isRecording();
const elapsedSeconds = await NosmaiCameraSdk.getCurrentRecordingDuration();
Replace the log with a guarded UI update. Progress and elapsed-time queries are not completion signals; use stopRecording() for the finalized file. Remove the subscription when its owner leaves:
progressSubscription.remove();
Lifecycle rule
Stop recording before camera switch, app pause, navigation, or cleanup. If an optional package-audio track cannot be muxed, inspect E_RECORDING_AUDIO_MUX and verify the finalized result instead of assuming the video was lost.
Verify it worked
Record a short clip with a visible effect, wait for stopRecording, and play the returned URI. Confirm its duration, audio, orientation, and effect output.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
| Recording does not start | NosmaiCameraView is not ready or a session is already active | Wait for camera startup and block duplicate record-button taps |
E_RECORDING_AUDIO_MUX | The optional audio track could not be finalized with the video | Inspect the result and verify native audio permissions and lifecycle |