我正在努力使用 Meteor 的 mdg:camera 插件向我的应用程序添加照片功能。目前,我没有任何 PhoneGap 设备设置,因此我正在我的笔记本电脑上进行测试。我想我在某处读到,当相机不可用时,Meteor 实现会回退并使用简单的文件对话框,但是当我尝试在笔记本电脑上运行以下代码时:
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
尝试从网络摄像头获取视频流,它不允许用户上传照片。
https://github.com/meteor/mobile-packages/blob/master/packages/mdg:camera/photo-browser.js#L41 https://github.com/meteor/mobile-packages/blob/master/packages/mdg:camera/photo-browser.js#L41
不幸的是,就在我们说话的时候getUserMedia
缺乏对 Safari 的支持,这可能是您在 MacBook 上使用的浏览器。
http://caniuse.com/#feat=stream http://caniuse.com/#feat=stream
请在 Google Chrome 或 Firefox 上尝试您的应用程序。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)