examples/phonegap1/plugins/cordova-plugin-media-capture/src/windows/CaptureProxy.js
function (successCallback, errorCallback) {
            try {
                createCameraUI();
                startCameraPreview(function () {
                    // This callback called twice: whem video capture started and when it ended
                    // so we need to check capture status
                    if (!captureStarted) {
                        // remove cancel button and rename 'Take' button to 'Stop'
                        toggleElements('cancelCapture');
                        document.getElementById('takePicture').text = 'Stop';

                        var encodingProperties = Windows.Media.MediaProperties.MediaEncodingProfile.createMp4(Windows.Media.MediaProperties.VideoEncodingQuality.auto),
                            generateUniqueCollisionOption = Windows.Storage.CreationCollisionOption.generateUniqueName,
                            localFolder = Windows.Storage.ApplicationData.current.localFolder;

                        localFolder.createFileAsync("cameraCaptureVideo.mp4", generateUniqueCollisionOption).done(function(capturedFile) {
                            capture.startRecordToStorageFileAsync(encodingProperties, capturedFile).done(function() {
                                capturedVideoFile = capturedFile;
                                captureStarted = true;
                            }, function(err) {
                                destroyCameraPreview();
                                errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, err);
                            });
                        }, function(err) {
                            destroyCameraPreview();
                            errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, err);
                        });
                    } else {
                        capture.stopRecordAsync().done(function () {
                            destroyCameraPreview();
                            successCallback(capturedVideoFile);
                        });
                    }
                }, errorCallback);
            } catch (ex) {
                destroyCameraPreview();
                errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, ex);
            }
        }
function (successCallback, errorCallback) {
            try {
                createCameraUI();
                startCameraPreview(function () {
                    // This callback called twice: whem video capture started and when it ended
                    // so we need to check capture status
                    if (!captureStarted) {
                        // remove cancel button and rename 'Take' button to 'Stop'
                        toggleElements('cancelCapture');
                        document.getElementById('takePicture').text = 'Stop';

                        var encodingProperties = Windows.Media.MediaProperties.MediaEncodingProfile.createMp4(Windows.Media.MediaProperties.VideoEncodingQuality.auto),
                            generateUniqueCollisionOption = Windows.Storage.CreationCollisionOption.generateUniqueName,
                            localFolder = Windows.Storage.ApplicationData.current.localFolder;

                        localFolder.createFileAsync("cameraCaptureVideo.mp4", generateUniqueCollisionOption).done(function(capturedFile) {
                            capture.startRecordToStorageFileAsync(encodingProperties, capturedFile).done(function() {
                                capturedVideoFile = capturedFile;
                                captureStarted = true;
                            }, function(err) {
                                destroyCameraPreview();
                                errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, err);
                            });
                        }, function(err) {
                            destroyCameraPreview();
                            errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, err);
                        });
                    } else {
                        capture.stopRecordAsync().done(function () {
                            destroyCameraPreview();
                            successCallback(capturedVideoFile);
                        });
                    }
                }, errorCallback);
            } catch (ex) {
                destroyCameraPreview();
                errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, ex);
            }
        }
function ( successCallback , errorCallback ) { try { createCameraUI ( ) ; startCameraPreview ( function ( ) { // This callback called twice: whem video capture started and when it ended // so we need to check capture status if ( ! captureStarted ) { // remove cancel button and rename 'Take' button to 'Stop' toggleElements ( 'cancelCapture' ) ; document . getElementById ( 'takePicture' ) . text = 'Stop' ; var encodingProperties = Windows . Media . MediaProperties . MediaEncodingProfile . createMp4 ( Windows . Media . MediaProperties . VideoEncodingQuality . auto ) , generateUniqueCollisionOption = Windows . Storage . CreationCollisionOption . generateUniqueName , localFolder = Windows . Storage . ApplicationData . current . localFolder ; localFolder . createFileAsync ( "cameraCaptureVideo.mp4" , generateUniqueCollisionOption ) . done ( function ( capturedFile ) { capture . startRecordToStorageFileAsync ( encodingProperties , capturedFile ) . done ( function ( ) { capturedVideoFile = capturedFile ; captureStarted = true ; } , function ( err ) { destroyCameraPreview ( ) ; errorCallback ( CaptureError . CAPTURE_INTERNAL_ERR , err ) ; } ) ; } , function ( err ) { destroyCameraPreview ( ) ; errorCallback ( CaptureError . CAPTURE_INTERNAL_ERR , err ) ; } ) ; } else { capture . stopRecordAsync ( ) . done ( function ( ) { destroyCameraPreview ( ) ; successCallback ( capturedVideoFile ) ; } ) ; } } , errorCallback ) ; } catch ( ex ) { destroyCameraPreview ( ) ; errorCallback ( CaptureError . CAPTURE_INTERNAL_ERR , ex ) ; } }
Initiate video capture using MediaCapture class
@param  {function} successCallback Called, when user clicked on preview, with captured file object
@param  {function} errorCallback   Called on any error
Initiate video capture using MediaCapture class