examples/phonegap1/plugins/cordova-plugin-media-capture/src/windows/CaptureProxy.js
function (successCallback, errorCallback) {
            try {
                createCameraUI();
                startCameraPreview(
                    // Callback for Take button - captures intermediate image file.
                    function () {
                        var encodingProperties = Windows.Media.MediaProperties.ImageEncodingProperties.createJpeg(),
                            overwriteCollisionOption = Windows.Storage.CreationCollisionOption.replaceExisting,
                            tempFolder = Windows.Storage.ApplicationData.current.temporaryFolder;

                        tempFolder.createFileAsync("cameraCaptureImage.jpg", overwriteCollisionOption).done(function (capturedFile) {
                            capture.capturePhotoToStorageFileAsync(encodingProperties, capturedFile).done(function () {
                                // store intermediate result in object's global variable
                                capturedPictureFile = capturedFile;
                                // show pre-captured image and toggle visibility of all buttons
                                previewContainer.style.backgroundImage = 'url("' + 'ms-appdata:///temp/' + capturedFile.name + '")';
                                toggleElements('capturePreview', 'takePicture', 'cancelCapture', 'selectPicture', 'retakePicture');
                            }, function (err) {
                                destroyCameraPreview();
                                errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, err);
                            });
                        }, function (err) {
                            destroyCameraPreview();
                            errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, err);
                        });
                    },
                    // error + cancel callback
                    function (err) {
                        destroyCameraPreview();
                        errorCallback(err);
                    },
                    // Callback for Select button - copies intermediate file into persistent application's storage
                    function () {
                        var generateUniqueCollisionOption = Windows.Storage.CreationCollisionOption.generateUniqueName,
                            localFolder = Windows.Storage.ApplicationData.current.localFolder;

                        capturedPictureFile.copyAsync(localFolder, capturedPictureFile.name, generateUniqueCollisionOption).done(function (copiedFile) {
                            destroyCameraPreview();
                            successCallback(copiedFile);
                        }, function(err) {
                            destroyCameraPreview();
                            errorCallback(err);
                        });
                    },
                    // Callback for retake button - just toggles visibility of necessary elements
                    function () {
                        toggleElements('capturePreview', 'takePicture', 'cancelCapture', 'selectPicture', 'retakePicture');
                    }
                );
            } catch (ex) {
                destroyCameraPreview();
                errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, ex);
            }
        }
function (successCallback, errorCallback) {
            try {
                createCameraUI();
                startCameraPreview(
                    // Callback for Take button - captures intermediate image file.
                    function () {
                        var encodingProperties = Windows.Media.MediaProperties.ImageEncodingProperties.createJpeg(),
                            overwriteCollisionOption = Windows.Storage.CreationCollisionOption.replaceExisting,
                            tempFolder = Windows.Storage.ApplicationData.current.temporaryFolder;

                        tempFolder.createFileAsync("cameraCaptureImage.jpg", overwriteCollisionOption).done(function (capturedFile) {
                            capture.capturePhotoToStorageFileAsync(encodingProperties, capturedFile).done(function () {
                                // store intermediate result in object's global variable
                                capturedPictureFile = capturedFile;
                                // show pre-captured image and toggle visibility of all buttons
                                previewContainer.style.backgroundImage = 'url("' + 'ms-appdata:///temp/' + capturedFile.name + '")';
                                toggleElements('capturePreview', 'takePicture', 'cancelCapture', 'selectPicture', 'retakePicture');
                            }, function (err) {
                                destroyCameraPreview();
                                errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, err);
                            });
                        }, function (err) {
                            destroyCameraPreview();
                            errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, err);
                        });
                    },
                    // error + cancel callback
                    function (err) {
                        destroyCameraPreview();
                        errorCallback(err);
                    },
                    // Callback for Select button - copies intermediate file into persistent application's storage
                    function () {
                        var generateUniqueCollisionOption = Windows.Storage.CreationCollisionOption.generateUniqueName,
                            localFolder = Windows.Storage.ApplicationData.current.localFolder;

                        capturedPictureFile.copyAsync(localFolder, capturedPictureFile.name, generateUniqueCollisionOption).done(function (copiedFile) {
                            destroyCameraPreview();
                            successCallback(copiedFile);
                        }, function(err) {
                            destroyCameraPreview();
                            errorCallback(err);
                        });
                    },
                    // Callback for retake button - just toggles visibility of necessary elements
                    function () {
                        toggleElements('capturePreview', 'takePicture', 'cancelCapture', 'selectPicture', 'retakePicture');
                    }
                );
            } catch (ex) {
                destroyCameraPreview();
                errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, ex);
            }
        }
function ( successCallback , errorCallback ) { try { createCameraUI ( ) ; startCameraPreview ( // Callback for Take button - captures intermediate image file. function ( ) { var encodingProperties = Windows . Media . MediaProperties . ImageEncodingProperties . createJpeg ( ) , overwriteCollisionOption = Windows . Storage . CreationCollisionOption . replaceExisting , tempFolder = Windows . Storage . ApplicationData . current . temporaryFolder ; tempFolder . createFileAsync ( "cameraCaptureImage.jpg" , overwriteCollisionOption ) . done ( function ( capturedFile ) { capture . capturePhotoToStorageFileAsync ( encodingProperties , capturedFile ) . done ( function ( ) { // store intermediate result in object's global variable capturedPictureFile = capturedFile ; // show pre-captured image and toggle visibility of all buttons previewContainer . style . backgroundImage = 'url("' + 'ms-appdata:///temp/' + capturedFile . name + '")' ; toggleElements ( 'capturePreview' , 'takePicture' , 'cancelCapture' , 'selectPicture' , 'retakePicture' ) ; } , function ( err ) { destroyCameraPreview ( ) ; errorCallback ( CaptureError . CAPTURE_INTERNAL_ERR , err ) ; } ) ; } , function ( err ) { destroyCameraPreview ( ) ; errorCallback ( CaptureError . CAPTURE_INTERNAL_ERR , err ) ; } ) ; } , // error + cancel callback function ( err ) { destroyCameraPreview ( ) ; errorCallback ( err ) ; } , // Callback for Select button - copies intermediate file into persistent application's storage function ( ) { var generateUniqueCollisionOption = Windows . Storage . CreationCollisionOption . generateUniqueName , localFolder = Windows . Storage . ApplicationData . current . localFolder ; capturedPictureFile . copyAsync ( localFolder , capturedPictureFile . name , generateUniqueCollisionOption ) . done ( function ( copiedFile ) { destroyCameraPreview ( ) ; successCallback ( copiedFile ) ; } , function ( err ) { destroyCameraPreview ( ) ; errorCallback ( err ) ; } ) ; } , // Callback for retake button - just toggles visibility of necessary elements function ( ) { toggleElements ( 'capturePreview' , 'takePicture' , 'cancelCapture' , 'selectPicture' , 'retakePicture' ) ; } ) ; } catch ( ex ) { destroyCameraPreview ( ) ; errorCallback ( CaptureError . CAPTURE_INTERNAL_ERR , ex ) ; } }
Initiate image 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 image capture using MediaCapture class