在笔记本电脑上测试时使用 MeteorCamera.getPicture() 拍照时出错 [英] Error while taking pictures using MeteorCamera.getPicture() while testing on a laptop

查看:37
本文介绍了在笔记本电脑上测试时使用 MeteorCamera.getPicture() 拍照时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Meteor 的 mdg:camera 插件为我的应用添加照片功能.目前,我没有任何 PhoneGap 设备设置,所以我正在我的笔记本电脑上进行测试.我以为我在某处读到 Meteor 实现会在相机不可用时回退并使用简单的文件对话框,但是当我尝试在我的笔记本电脑上运行以下代码时:

I am working to add a photo ability to my app using Meteor's mdg:camera plugin. For now, I don't have any PhoneGap devices setup, so I am testing on my laptop. I thought I read somewhere that the Meteor implementation would fall-back and use a simple file dialog when a camera wasn't available, but when I try to run the following code on my laptop:

var cameraOptions = {
    width: 800,
    height: 600
};

MeteorCamera.getPicture(cameraOptions, function (err, data) {
    if (err) {
        console.log(err);
        // TODO Need to handle the error
    } else {
        if (!this.photos) {
            this.photos = [];
        }

        this.photos.push({ submitted_by: Meteor.userId(), submitted_on: new Date(), photo_data: data});
    }
});

我收到错误:

Meteor.makeErrorType.errorClass {error: "unknownError", reason: "There was an error while accessing the camera.", details: undefined, message: "There was an error while accessing the camera. [unknownError]", errorType: "Meteor.Error"…}

我实际上希望用户在使用笔记本电脑时能够通过同一个按钮上传照片.就其价值而言,我确实内置了一个摄像头,而且我正在 15 英寸 MacBook Pro 上进行开发.

I would actually like for users to be able to upload photos via the same button when using a laptop. For what it's worth, I actually do have a camera built-in, and I am developing on a 15" MacBook Pro.

推荐答案

在浏览器客户端,mdg:camera 依靠使用 navigator.getUserMedia 来尝试获取来自网络摄像头的视频流,它不允许用户上传照片.

On browser client, the mdg:camera falls back on using navigator.getUserMedia to try to obtain a video stream from the webcam, it does not allow the user to upload a photo.

https://github.com/meteor/mobile-packages/blob/master/packages/mdg:camera/photo-browser.js#L41

不幸的是,正如我们所说,getUserMedia 缺乏对 Safari 的支持,这可能是您在 MacBook 上使用的浏览器.

Unfortunately as we are speaking getUserMedia lacks support on Safari, which is probably the browser you are using working on a MacBook.

http://caniuse.com/#feat=stream

改为在 Google Chrome 或 Firefox 上试用您的应用程序.

Try your application on Google Chrome or Firefox instead.

这篇关于在笔记本电脑上测试时使用 MeteorCamera.getPicture() 拍照时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆