初始拒绝后,使用getUserMedia()重新授予权限 [英] reprompt for permissions with getUserMedia() after initial denial

查看:1346
本文介绍了初始拒绝后,使用getUserMedia()重新授予权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何在拒绝一次后使用getUserMedia()请求摄像头/麦克风访问?

How do we go about requesting camera/microphone access with getUserMedia() after being denied once?

我正在使用getUserMedia访问用户的摄像头和管道数据到画布。这一切都很好。

I'm working with getUserMedia to access the user's camera and pipe the data to a canvas. That bit all works fine.

在测试中,我打了一次拒绝。此时在Chrome和Firefox中,任何带有getUserMedia()的后续请求都默认为拒绝状态。

In testing, I hit deny once. At this point in Chrome and Firefox, any subsequent requests with getUserMedia() default to the denied state.

我们显然不希望通过在拒绝后的每个页面加载时请求摄像头/麦克风的权限来惹恼我们的用户。对地理位置api来说已经足够烦人了。

We obviously don't want to annoy the hell out of our users by requesting permissions for camera/microphone on every page load after being denied. That's already annoying enough with the geolocation api.

但是,必须有办法再次申请。仅仅因为用户点击拒绝一次并不意味着他们想要一直拒绝网络摄像头访问。

However, there has to be a way to request it again. Simply because a user hit deny once doesn't mean they want to deny webcam access for all time.

我一直在阅读有关规范和谷歌搜索一段时间但是我没有明确地发现这个问题。

I've been reading about the spec and googling around for a while but I'm not finding anything explicitly about this problem.

编辑:
进一步研究,看来在Chrome中点击Deny会将当前网站添加到块中名单。这可以通过chrome:// settings / content手动访问。滚动到媒体。管理例外,删除被阻止的网站。

Further research, it appears that hitting Deny in Chrome adds the current site to a block list. This can be manually accessed via chrome://settings/content. Scroll to Media. Manage Exceptions, remove the blocked site(s).

链接到chrome:// settings / content不起作用(如果我们想要添加有用的话)链接让人们重新启用权限)。

Linking to chrome://settings/content doesn't work (in the case where we want to add a helpful link to let people re-enable permissions).

处理getUserMedia周围权限的整个用户体验很糟糕。 =(

The whole UX for dealing with permissions around getUserMedia stinks. =(

推荐答案

使用HTTPS。当用户授予一次权限时,会记住它并且Chrome不会再次请求该页面的权限并且您可以立即访问媒体。这不会为您提供再次强制用户权限栏的方法,但至少确保您在用户授予权限一次后不必继续请求它。

Use HTTPS. When the user gives permission once, it's remembered and Chrome does not ask for permission for that page again and you get access to the media immediately. This does not provide you a way to force the permission bar on the user again, but atleast makes sure you don't have to keep asking for it once the user grants the permission once.


如果你的应用程序是从SSL(https://)运行的,那么这个权限将是持久的。也就是说,用户不必授予/每次拒绝访问。

If your app is running from SSL (https://), this permission will be persistent. That is, users won't have to grant/deny access every time.

请参阅: http://www.html5rocks.com/en/tutorials/getusermedia/intro/

这篇关于初始拒绝后,使用getUserMedia()重新授予权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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