HTML5相机API - 在Chrome中不起作用? [英] HTML5 Camera API - Not working in Chrome?

查看:266
本文介绍了HTML5相机API - 在Chrome中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了这篇文章: http: //www.syntaxxx.com/accessing-user-device-photos-with-the-html5-camera-api/

使用我的桌面,它适用于Firefox。在Chrome中它不起作用。它说:

Using my desktop, it works in Firefox. In Chrome it doesn't work though. It says:

Failed to load resource: the server responded with a status of 404 (Not Found)  
blob:http%3A//localhost/a4368515-b68f-43ff-8e11-c888bc90b93b

在我链接的文章中其中一位评论者说它在Chrome中不起作用(所以不仅仅是我),但没有发布解决方案。

In the article I linked to, one of the commenters said it didn't work in Chrome (so it's not only me) but there is no solution posted.

这里有没有人知道为什么代码在Chrome中不起作用?

Does anyone here know why that code won't work in Chrome?

推荐答案

在这种情况下,本文正在发布Blob对象(使用在请求发出之前,revokeObjectURL ),因此当图像请求blob时,它不再存在。 Chrome是规范兼容,示例应检查图片是否已加载在撤销Blob URL之前。

In this case the article is releasing the Blob Object (using revokeObjectURL) before the request has been made, so when the image requests the blob it is no longer there. Chrome is Specification compliant, the sample should check that the image has loaded before revoking the Blob URL.

请参阅 https:/ /jsbin.com/viyepa/1/edit 对于一个有效的示例,我已经注释掉了 revokeObjectURL ,现在它可以正常工作了。如果将其重新添加,则会失败。

See https://jsbin.com/viyepa/1/edit for an example that works, I have commented out revokeObjectURL and it now works. If you add it back in, it will fail.

这篇关于HTML5相机API - 在Chrome中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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