closeio / mic-recorder-to-mp3

Microphone Recorder to mp3
MIT License
244 stars 138 forks source link

Removed deviceId constraint from getUserMedia() #5

Closed benmackerras closed 6 years ago

benmackerras commented 6 years ago

Bug fix for firefox OverconstrainedError. Since we were just setting deviceId to 'default' I think its ok to remove.

benmackerras commented 6 years ago

In reference to https://github.com/closeio/mic-recorder-to-mp3/issues/3

djalmaaraujo commented 6 years ago

@buzinas 👆

frumbert commented 6 years ago

This works for me on Firefox 63.0.1 macos as well as Chrome 70.0.3538.77 (macos) ..

buzinas commented 6 years ago

Since we were just setting deviceId to 'default' I think its ok to remove.

We are setting deviceId to 'default' as default, but this config exists to be overwritten by the consumer. Check Object.assign(this.config, config). This PR would break the current code.

~Btw, I can't reproduce the problem, what are the steps @benmackerras?~


Edit: I was able to reproduce the problem, and it happens because Firefox no longer has a 'default' deviceId. The ideal PR would remove the 'default' on the constructor and then do something like:

const audio = this.config.deviceId ? { deviceId: { exact: this.config.deviceId } } : true;

For now, you can workaround it to make the library work on Firefox with something like:

navigator.userMedia.enumerateDevices().then(devices => {
  const recorder = new MicRecorder({
    deviceId: devices.find(device => device.kind ==='audioinput').deviceId,
  });

  // and the rest is the same
});