【问题标题】:Cordova take photo in the background科尔多瓦在后台拍照
【发布时间】:2018-02-17 09:52:59
【问题描述】:

我正在制作一个必须在后台拍照的应用程序,即没有交互。当前使用的是cordova-plugin-camera,但这会打开一个交互式选项,用户必须从中手动单击照片。

navigator.camera.getPicture(successCallback, FailCallback, {
    destinationType: Camera.DestinationType.DATA_URL,
    cameraDirection: 1,
    quality: 25,
    targetWidth: 300,
    targetHeight: 300
});

【问题讨论】:

    标签: android cordova cordova-plugins onsen-ui monaca


    【解决方案1】:

    使用CameraPictureBackground插件:

    示例代码:

    function success(imgurl) {
      console.log("Imgurl = " + imgurl);
    }
    
    function onFail(message) {
        alert('Failed because: ' + message);
    }
    
    function CaptureBCK() {
        var options = {
          name: "Image", //image suffix
          dirName: "CameraPictureBackground", //foldername
          orientation: "portrait", //or landscape
          type: "back" //or front
        };
    
        window.plugins.CameraPictureBackground.takePicture(success, onFail, options);
    }
    
    <button onclick="CaptureBCK();">Capture Photo</button>
    

    您将在您的设备存档中的 CameraPictureBackground 目录下找到您的图片。

    【讨论】:

    • 我收到此类型错误:无法读取未定义的属性“takePicture”。
    • 你安装了CameraPictureBackground插件吗?
    • 是的,我这样做了,而且 monaca 工具包检测到了它
    猜你喜欢
    • 2015-03-30
    • 2015-01-25
    • 2023-04-03
    • 1970-01-01
    • 2018-06-03
    • 1970-01-01
    • 2017-06-30
    • 1970-01-01
    相关资源
    最近更新 更多