当您在Firefox中选择“不是现在”时,getUserMedia不会触发错误回调 [英] getUserMedia doesn't trigger error callback when you choose 'Not now' in Firefox

查看:757
本文介绍了当您在Firefox中选择“不是现在”时,getUserMedia不会触发错误回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



编辑:编辑: 我已经向您展示了这个问题: http://jsfiddle.net/4rgRY/

  navigator.getUserMedia = navigator.getUserMedia || 
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia; $ {

if(navigator.getUserMedia){
navigator.getUserMedia({audio:true,video:false},function(stream){
console.log('Yayy!' );
},function(err){
console.log(There was an error->:,err);
});
} else {
console.log('getUserMedia not supported');



$ b

它在Chrome中正常工作,但是当我尝试在Firefox(27和Firefox Nightly 30a1),并选择不是现在,它不会触发任何回调,无论是成功还是错误回调。所以我的应用程序认为这是允许的,但无法正常工作。



如果您在Firefox中选择其他选项,如始终共享,绝不共享或不共享,工作正常,只是与'不是现在'选项。

可能是一个Firefox的错误?或者是我的代码错了?

解决方案

Not now意思就是说:用户还没有做出是否允许还是拒绝的决定。用户选择后,他们可以重新打开要求许可的弹出窗口(通过点击小的视频图标,如果选择了该选项,该窗口将停留在周围),并选择是否允许。



基本上,点击不是现在与下面的用户操作完全一样:


  1. 在Firefox中,只需点击小提琴上出现的弹出框外部即可。即使没有选择任何选项,也不用选择任何选项。

  2. 在Chrome中,只是忽略请求权限的信息栏,而不是点击任何内容。 b

,您的代码应该像处理这些用户操作一样处理它。


i'm trying to write a script to detect when the user allow/deny the use of a microphone, using the getUserMedia API.

EDIT: I've made a fiddle to show you the issue: http://jsfiddle.net/4rgRY/

navigator.getUserMedia  = navigator.getUserMedia ||
                      navigator.webkitGetUserMedia ||
                      navigator.mozGetUserMedia ||
                      navigator.msGetUserMedia;

if (navigator.getUserMedia) {
  navigator.getUserMedia({audio: true, video: false}, function(stream) {
    console.log('Yayy!');
  }, function(err){
    console.log("There was an error->: ",err);
  });
} else {
  console.log('getUserMedia not supported');
}

It works fine at Chrome but when i tried in Firefox (27 and Firefox Nightly 30a1), and you choose 'Not now', it doesn't trigger any callback, either the success or the error callbacks. So my app thinks that is allowed but doesn't work properly.

If you choose any other option in Firefox, like Always Share, Never Share or Don't Share, works fine, is just with the 'Not now' option.

Could be a Firefox bug? Or is something wrong with my code?

解决方案

"Not now" means exactly what it says: The user hasn't made a decision about whether to allow or deny yet. After the user selects it, they can reopen the popup that asked for the permission (by clicking on the little video icon, which sticks around if that option is chosen) and choose whether to grant it or not.

Basically, clicking "Not now" is exactly the same as the following user actions:

  1. In Firefox, just clicking outside the popup that comes up on your fiddle. That dismisses the popup, without selecting any of the options.
  2. In Chrome, simply ignoring the infobar that's requesting the permission and not clicking anything at all in it.

and your code should handle it just like it handles those user actions.

这篇关于当您在Firefox中选择“不是现在”时,getUserMedia不会触发错误回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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