This plugin allows you to save local Video file to the iOS Camera Roll. The video file to be saved to the Library/Gallery must be available on the device.
The plugin is based on code seen in several other existing plugins:
- SaveVideo By quiply
- Canvas2VideoPlugin by Tommy-Carlos Williams
- ImgDownloader by Nomia
- cordova-camera-roll by Max Lynch
Thanks to all of the above mentioned authors for sharing their code openly.
cordova plugin add https://github.com/AnasFullStack/cordova-plugin-save-video.git --nofetch
- cordova.plugins.saveVideoToGallery
none
Save a local video to the device gallery.
window.cordova.plugins.saveVideoToGallery(nativePathToVideo, successCallback, errorCallback);
- iOS
Call the window.cordova.plugins.saveVideoToGallery()
method passing 3 parameters:
- The native video path for the video to be saved
- success callback
- error callback
// iOS with file prefix: var nativePathToVideo = 'file:///var/mobile/Containers/Data/Application/<UUID>/Library/NoCloud/some_dir/some_video.mp4'
// iOS without file prefix: var nativePathToVideo = '/var/mobile/Containers/Data/Application/<UUID>/Library/NoCloud/some_dir/some_video.mp4'
window.cordova.plugins.saveVideoToGallery(nativePathToVideo, onSaveVideoSuccess, onSaveVideoError);
function onSaveVideoSuccess() {
console.log('--------------success');
}
function onSaveVideoError(error) {
console.log('--------------error: ' + error);
}