startCameraPreview()

in src/windows/CaptureProxy.js [182:220]


                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';

                        const encodingProperties = Windows.Media.MediaProperties.MediaEncodingProfile.createMp4(
                            Windows.Media.MediaProperties.VideoEncodingQuality.auto
                        );
                        const generateUniqueCollisionOption = Windows.Storage.CreationCollisionOption.generateUniqueName;
                        const 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);