Library (Photo + Video) & Capture (Photo + Video)
Minimum iOS 9.0 & above.
To test kindly download the example and run videoPlugin.xcworkspace under platform -> ios section.
Resource plugin list :
- cordova-plugin-camera-preview
- cordova-plugin-photo-library
- cordova-plugin-video-editor
- cordova-plugin-instagram-assets-picker
To integrate with your project , download the resource plugins & replace their exsiting files with our files after successfully building ios project.
- Run a camera session.
CameraPreview.startCamera(options, function() {
console.log('successCamera')
}, function(error) {
alert(error) }
);
- Load / Intialise the Device Library.
InstagramAssetsPicker.getMedia(
function(result) { // success cb
console.log('getMedia success, result: ', JSON.stringify(result, null, 2));
},
function(err) { // error cb
console.log('getMedia error, err: ', err);
}, { // options
type: 'all', // accepts 'photo', 'video', or 'all' - defaults to all
cropAfterSelect: false, // see the note above for when this is false - defaults to false
showGrid: false // determines whether to show the grid for cropping - defaults to false
}
);
- Add Capture Function for image capture.
CameraPreview.takePicture({ width: 640, height: 640, quality: 85, type: 1 }, function(pictureSource) {
imageSrcData = 'data:image/jpeg;base64,' + pictureSource;
}, function(error) { alert(error) });
- Recording Start / Stop Instance for Video Recording.
CameraPreview.takePicture({ width: 640, height: 640, quality: 85, type: 2 }, function(videoSource) {
// alert(videoSource);
}, function(error) { alert(error) });
toggle same function for start & stop recording.
- After selecting a video / recording a video Trim video into 20 sec with help of Video Slider & Trim video.
VideoEditor.trim(
trimSuccess,
trimFail, {
fileUri: // 'file-uri-here', // path to input video
trimStart: 0, // time to start trimming in seconds
trimEnd: 15, // time to end trimming in seconds
outputFileName: 'ov' + Date.parse(new Date()), // output file name
progress: function(info) {} // optional, see docs on progress
}
);
- After Trim select a thumbnail from thumbnail slider.
VideoEditor.createThumbnail(
success, // success cb
error, // error cb
{
fileUri: // 'file-uri-here', // path to input video
outputFileName: 'thumbnail-image' + Date.parse(new Date()), // output file name
atTime: 10, // optional, location in the video to create the thumbnail (in seconds)
width: 320, // optional, width of the thumbnail
height: 480, // optional, height of the thumbnail
quality: 100 // optional, quality of the thumbnail (between 1 and 100)
}
);
- Output - Trim Video + Thumbnail Image for Video.
- Optional - Switch camera view + flash mode (on/off).
CameraPreview.getFlashMode(function(currentFlashMode) {
var mode = currentFlashMode;
if (mode == "on") {
CameraPreview.setFlashMode(CameraPreview.FLASH_MODE.OFF);
} else {
CameraPreview.setFlashMode(CameraPreview.FLASH_MODE.ON);
}
});
- Reference for functions : index.js under www folder.
Thankyou, Credits : http://www.terasoltechnologies.com/