OpenTok accessDenied issue in Chrome

I'm having some trouble with the OpenTok 2 API. When I start to publish a stream and I'm prompted to allow or deny the website to use my webcam and microphone, if I allow allowed() should run, but if I deny denied() should run.

publisher.addEventListener('accessAllowed', allowed);
publisher.addEventListener('accessDenied', denied);

function allowed() {

function denied() {

It works as expected in Firefox. In Chrome accessAllowed works, however, accessDenied doesn't. Instead I get the following error:

OT.Publisher.onStreamAvailableError PermissionDeniedError:
TB.exception :: title: Internal Error (2000) msg: Publisher failed to access camera/mic:

Any ideas?



This is a bug in the current JS library at OpenTok. I do have a workaround that should get you going and I'll come back with an update when the bug is fixed.

var waiting = false;
publisher.addEventListener('accessAllowed', function() {
  waiting = false;
publisher.addEventListener('accessDenied', function() {
  waiting = false;
publisher.addEventListener('accessDialogOpened', function() {
  waiting = true;
publisher.addEventListener('accessDialogClosed', function() {
  setTimeout(function() {
    if (waiting) {
      waiting = false;
  }, 0);

This workaround is slightly limited because Chrome has some weirdness when it comes to denying access once and then visiting the page again. If the user hasn't changed his/her preferences regarding the media permissions, the video will continue to be denied and the 'accessDialogOpened' won't even fire. I'll inform the team and continue to look into this.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.