在笔记本上测试时使用MeteorCamera.getPicture()拍摄照片时出现错误
问题描述:
我正在使用Meteor的mdg:照相机插件为我的应用添加照片功能。目前,我没有任何PhoneGap设备设置,所以我正在测试我的笔记本电脑。我想我读的地方,流星实施将回落和使用简单文件对话框时相机是不可用的,但是当我尝试在我的笔记本电脑运行下面的代码:在笔记本上测试时使用MeteorCamera.getPicture()拍摄照片时出现错误
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。
答
在浏览器客户端上,mdg:camera
使用navigator.getUserMedia
尝试获取视频流网络摄像头,因为我们讲getUserMedia
它不允许用户上传照片。
https://github.com/meteor/mobile-packages/blob/master/packages/mdg:camera/photo-browser.js#L41
遗憾的是缺乏关于Safari浏览器,这可能是您使用的是一台MacBook工作的浏览器的支持。
http://caniuse.com/#feat=stream
请在Google Chrome或Firefox上尝试您的应用程序。
我实际上使用的是Chrome。 Safari是魔鬼。任何提示让它工作?我知道我的摄像头指示灯已熄灭,所以也许是因为我以某种方式禁用了它? – CodeChimp 2014-10-03 15:50:42
在Chrome浏览器地址栏的最右侧,你应该看到一个摄像头图标,如果它被禁用,它将被划掉红色,点击它来更改权限,如果一切正常,你应该被提示用户许可在执行对'getUserMedia'的调用时访问摄像头。 – saimeunt 2014-10-03 15:52:48
天才!谢谢! – CodeChimp 2014-10-03 15:58:32