Javascript 无法使用Cordova打开前置摄像头

Javascript 无法使用Cordova打开前置摄像头,javascript,cordova,Javascript,Cordova,我已经完成了我的应用程序的所有部分,现在我需要使用前摄像头而不是后摄像头进行扫描,但无法打开它 这是相机的脚本 function scanTrivago() { cordova.plugins.barcodeScanner.scan( function (result) { if(!result.cancelled) { trivagoNumber(result.text);

我已经完成了我的应用程序的所有部分,现在我需要使用前摄像头而不是后摄像头进行扫描,但无法打开它

这是相机的脚本

    function scanTrivago()
{
    cordova.plugins.barcodeScanner.scan(
        function (result) {
            if(!result.cancelled)
            {
                trivagoNumber(result.text);
                path="/confirm-checkin-1/";
        //    alert("Barcode type is: " + result.format);
        //    alert("Decoded text is: " + result.text);
            }
            else
            {
                trivagoNumber(result.text);
              path="/check-in/";
            }
        },

        function (error) {
          alert("Scanning failed: " + error);
        }
    );
}
我使用的正是这个网站上的功能,我的简单javascript一切都很好,但无法将摄像头切换到前端。

有一个更好的使用示例,包括一个
首选FrontCamera
选项:

一个完整的例子可以是:

   cordova.plugins.barcodeScanner.scan(
      function (result) {
          alert("We got a barcode\n" +
                "Result: " + result.text + "\n" +
                "Format: " + result.format + "\n" +
                "Cancelled: " + result.cancelled);
      },
      function (error) {
          alert("Scanning failed: " + error);
      },
      {
          preferFrontCamera : true, // iOS and Android
          showFlipCameraButton : true, // iOS and Android
          showTorchButton : true, // iOS and Android
          torchOn: true, // Android, launch with the torch switched on (if available)
          saveHistory: true, // Android, save scan history (default false)
          prompt : "Place a barcode inside the scan area", // Android
          resultDisplayDuration: 500, // Android, display scanned text for X ms. 0 suppresses it entirely, default 1500
          formats : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED
          orientation : "landscape", // Android only (portrait|landscape), default unset so it rotates with the device
          disableAnimations : true, // iOS
          disableSuccessBeep: false // iOS and Android
      }
   );