code: function startCameraPreview(takeCallback, errorCallback, selectCallback, retakeCallback) {
          // try to select appropriate device for capture
          // rear camera is preferred option
          var expectedPanel = Windows.Devices.Enumeration.Panel.back;
          Windows.Devices.Enumeration.DeviceInformation.findAllAsync(Windows.Devices.Enumeration.DeviceClass.videoCapture).done(function (devices) {
              if (devices.length > 0) {
                  devices.forEach(function (currDev) {
                      if (currDev.enclosureLocation && currDev.enclosureLocation.panel && currDev.enclosureLocation.panel == expectedPanel) {
                          captureSettings.videoDeviceId = currDev.id;
                      }
                  });
  
                  capture.initializeAsync(captureSettings).done(function () {
                      // This is necessary since WP8.1 MediaCapture outputs video stream rotated 90 degrees CCW
                      // TODO: This can be not consistent across devices, need additional testing on various devices
                      // msdn.microsoft.com/en-us/library/windows/apps/hh452807.aspx
                      capture.setPreviewRotation(Windows.Media.Capture.VideoRotation.clockwise90Degrees);
                      capturePreview.msZoom = true;
  
                      capturePreview.src = URL.createObjectURL(capture);
                      capturePreview.play();
  
                      previewContainer.style.display = 'block';
  
                      // Bind events to controls
                      capturePreview.onclick = takeCallback;
                      document.getElementById('takePicture').onclick = takeCallback;
                      document.getElementById('cancelCapture').onclick = function () {
                          errorCallback(CaptureError.CAPTURE_NO_MEDIA_FILES);
                      };
                      document.getElementById('selectPicture').onclick = selectCallback;
                      document.getElementById('retakePicture').onclick = retakeCallback;
                  }, function (err) {
                      destroyCameraPreview();
                      errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, err);
                  });
              } else {
                  // no appropriate devices found
                  destroyCameraPreview();
                  errorCallback(CaptureError.CAPTURE_INTERNAL_ERR);
              }
          });
      }
docs: Starts camera preview and binds provided callbacks to controls
  @param  {function} takeCallback   Callback for Take button
  @param  {function} errorCallback  Callback for Cancel button + default error callback
  @param  {function} selectCallback Callback for Select button
  @param  {function} retakeCallback Callback for Retake button