Error while taking pictures using MeteorCamera.getPicture() while testing on a laptop

只愿长相守 提交于 2019-12-13 15:04:48

问题


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});
    }
});

I get the error:

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"…}

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.


回答1:


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

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

Try your application on Google Chrome or Firefox instead.



来源:https://stackoverflow.com/questions/26182267/error-while-taking-pictures-using-meteorcamera-getpicture-while-testing-on-a-l

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!