cordova-plugin-native-video-recorder
v1.3.0
Published
Video capture plugin for Cordova using CameraX
Maintainers
Readme
Cordova Native Video Recorder Plugin
A robust, secure, and highly-performant video recording plugin for Cordova and UI5 (Neptune DXP) apps on Android. It leverages the modern Android CameraX API for smooth video capturing.
Features
- 📸 Native CameraX Integration: Hardware-accelerated recording with beautiful native UI.
- ⚡ High Performance & Stability: Fixes the OutOfMemory crashes that plague HTML5
<video>capture. - 📂 Dual Storage Support: Saves videos reliably to the app's secure private storage and synchronizes them to the public Android Gallery (MediaStore).
- 🎬 Built-in Player Helper: Launch the system's native video player seamlessly.
- 🚀 UI5 / Neptune Ready: Drop-in compatible with standard JS frameworks.
Installation
You can install this plugin directly via npm or the Cordova CLI:
cordova plugin add cordova-plugin-native-video-recorder --saveSupported Platforms
- Android (API level 21+)
API Reference
The plugin is exposed via the window.VideoRecorder object. For legacy compatibility, it is also available via window.Video.
VideoRecorder.capture(successCallback, errorCallback)
Opens the native camera interface to record a video. The video is automatically saved in HD quality.
Parameters:
successCallback: A callback function that is called with the absolute file path (or URI) of the captured video.errorCallback: (Optional) A callback function that is called if an error occurs or the user cancels.
Example:
VideoRecorder.capture(function(videoPath) {
console.log("Video saved at: " + videoPath);
}, function(error) {
console.error("Capture failed: " + error);
});VideoRecorder.list(successCallback, errorCallback)
Lists all videos that have been recorded by the app in its private directory.
Parameters:
successCallback: A callback function that receives an array of video objects[{ name: "...", path: "...", size: 1024, date: 16200000 }].errorCallback: (Optional) A callback function that is called if an error occurs.
Example:
VideoRecorder.list(function(videos) {
videos.forEach(function(vid) {
console.log(vid.name + " (" + vid.size + " bytes)");
});
}, function(error) {
console.error("List failed: " + error);
});VideoRecorder.play(fileName, successCallback, errorCallback)
Plays a specific video using the default native video player of the Android system.
Parameters:
fileName: The name or absolute path of the video file to play.successCallback: A callback function called when the player is successfully launched.errorCallback: (Optional) A callback function that is called if no suitable video player is found.
Example:
VideoRecorder.play("20260709_120000.mp4", function() {
console.log("Playing video...");
}, function(error) {
console.error("Play failed: " + error);
});Security & Best Practices
- Privacy & Storage: Videos are stored privately within your application's scoped storage to comply with strict Android 11+ (API 30+) requirements. A copy is safely indexed into the MediaStore so the user can find their videos in their standard Photo Gallery.
- Data Retention: Deletion of recordings must be handled manually via the native file system tools or device gallery by the user to prevent accidental data loss. App-level programmatic deletion is disabled by design to comply with modern Android security best practices.
License
MIT License
