Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Please invoke getUserMedia once" on Microphones list on Android Firefox browser (v56.0) #56

Closed
Naehs opened this issue Nov 13, 2017 · 1 comment

Comments

@Naehs
Copy link

Naehs commented Nov 13, 2017

Hi Muaz,

First, thanks for your work.

I've remark that in my application i got the "Please invoke getUserMedia once" only for the microphone list on my Android Firefox browser (v56.0).
I thougth i was doing something wrong, but if you go on this page https://www.webrtc-experiment.com/DetectRTC/ on Androïd Firefox browser you will have the "Please invoke getUserMedia once".

How to fix this issue ?

Regards,
Loïc.

@Naehs
Copy link
Author

Naehs commented Dec 1, 2017

Hello,

If you go on this sample, everything works fine.
I mean for microphone detection, so for my opinion it's not a Firefox bug.

But i've noticed, on every Firefox browser, if you try to enumerate devices :

navigator.mediaDevices.enumerateDevices()
.then(function(devices) {  
  for (var i = 0, device; device = devices[i]; i++) {
    if (device.kind === 'audioinput') {
      console.log('device', device);
    }
  }
})
.catch(function(error) {
  console.log('error', error);
});

Before getting the user media :

var constraints = {
  audio: true
};

navigator.mediaDevices.getUserMedia(constraints)
.then(function(stream) {
  console.log('stream', stream);
})
.catch(function(error) {
  console.log('error', error);
});

That you will have an empty :

device.label;

But, if you do it like that, you will have the labels :

var constraints = {
  audio: true
};

navigator.mediaDevices.getUserMedia(constraints)
.then(function(stream) {
  console.log('stream', stream);

  navigator.mediaDevices.enumerateDevices()
  .then(function(devices) {  
    for (var i = 0, device; device = devices[i]; i++) {
      if (device.kind === 'audioinput') {
        console.log('device', device);
      }
    }
  })
  .catch(function(error) {
    console.log('error', error);
  });
})
.catch(function(error) {
  console.log('error', error);
});

However, in Android Firefox, only one "audioInput" is detected, with an empty label.
Maybe that you are testing the length of the "audioInput" list or the label returned for trigering the "Please invoke getUserMedia once" ?

It could be solved by incrementing the empty labels with the length of the list :

var nbMicrophones = 0;
var constraints = {
  audio: true
};

navigator.mediaDevices.getUserMedia(constraints)
.then(function(stream) {
  console.log('stream', stream);

  navigator.mediaDevices.enumerateDevices()
  .then(function(devices) {  
    for (var i = 0, device; device = devices[i]; i++) {
      if (device.kind === 'audioinput') {
        nbMicrophones++;
        console.log('device.label', (device.label.length > 0) ? device.label : 'Microphone ' + nbMicrophones);
      }
    }
  })
  .catch(function(error) {
    console.log('error', error);
  });
})
.catch(function(error) {
  console.log('error', error);
});

Regards,
Loïc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant