getUserMedia doesn't trigger error callback when you choose 'Not now' in Firefox

試著忘記壹切 提交于 2019-12-08 12:25:29

问题


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?


回答1:


"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.




回答2:


I guess an answer was not really given. How does my app detect the fact that the user decided to not make a choice? Not making a choice means that my app will not have access to camera and mic, therefore it should trigger the error callback in getUserMedia IMO.



来源:https://stackoverflow.com/questions/22250070/getusermedia-doesnt-trigger-error-callback-when-you-choose-not-now-in-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!