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

1k views Asked by At

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

There are 1 answers

3
saimeunt On BEST ANSWER

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.