【问题标题】:Cordova - Continously taking and uploading picturesCordova - 不断拍摄和上传照片
【发布时间】:2015-10-20 13:21:34
【问题描述】:

我正在对我一直在考虑的一个项目进行一些可行性研发,问题是我不熟悉相机 API 或操作系统本身的限制。

我想编写一个科尔多瓦应用程序,当打开(并授权)时,它将每隔 n 秒拍摄一张照片并将其上传到 FTP 站点。把它想象成一个闭路电视功能,我的网站会不断地向用户呈现最新的图像。

一些伪代码:

while (true) {
       var img = api.takePicture(args);
       uploadImage(img);
       thread.sleep(1000);
}

所以我的问题是,我可以访问相机并指示它在没有用户干预的情况下拍照(同样,在相机访问被授权后)? 任何 API 调用来完成它的示例或方向将不胜感激。我看到this 文章,答案看起来很有希望,但是 OP 有 android,我想知道它在 iOS 上的行为是否相同。

附带说明,如何在不购买应用商店许可证的情况下在 iPhone 上测试我的 cordova 应用程序?我只想在自己的设备上运行它。

【问题讨论】:

    标签: android ios iphone cordova


    【解决方案1】:

    使用CameraPictureBackground插件解决:

    function success(imgurl) {   console.log("Imgurl = " + imgurl);   //here I added my function to upload the saved pictures   //on my internet server using file-tranfer plugin }
    
    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> <br>

    您将在您的设备存档中的 CameraPictureBackground 目录下找到您的图片。我还使用了文件传输插件,以便通过互联网直接将图片上传到我的服务器上。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多