Prerequisites
- A working Android quickstart
- The active
NosmaiPreviewView - A writable absolute
.mp4output path
Start recording
NosmaiSDK.startRecording(previewView, outputPath,
new NosmaiSDK.RecordingCallback() {
@Override
public void onStarted(boolean success, String error) {
if (!success) {
Log.e("Nosmai", "Recording did not start: " + error);
}
}
});
Disable duplicate start requests until onStarted returns.
Stop and finalize the MP4
NosmaiSDK.stopRecording(new NosmaiSDK.RecordingCallback() {
@Override
public void onCompleted(String path, boolean success, String error) {
if (success) {
Log.i("Nosmai", "Video ready at " + path);
} else {
Log.e("Nosmai", "Recording failed: " + error);
}
}
});
Wait for onCompleted before opening, sharing, or scanning the file.
Lifecycle rule
Stop and finalize recording before switching camera, pausing the activity, or destroying the preview. On measured lower-tier devices the SDK can reduce only the recording resolution to protect frame rate; the live preview remains at its configured size.
Verify it worked
Record a short clip with a visible effect, wait for onCompleted, and play the returned MP4. Confirm its orientation, effect output, video duration, and audio.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
| Recording does not start | The preview is not ready or another start is in progress | Wait for camera startup and guard the record button |
| The file cannot be opened | The app used it before onCompleted | Wait for finalization and use a writable absolute .mp4 path |