I'm trying to acquire different MediaStreams while specifying a different deviceId
in each case.
For example: I have 3 microphones (audioinputs
) available and would like to acquire an audio stream for each of them.
deviceId
4hYbpq3YGKqNN6RbbLz5HrLfolsmjFDMl8sYdeviceId
MZ0gdxcs1Q0NW0sobM8ri3kfDhmOs1K74e2pstreamC3: with deviceId
iUWqFDfruPGcT6nl9gUxeN6dCM8VfFH5ZmR8
const c1 = { audio: { deviceId: { exact: audioInputs[0].deviceId } } };
const c2 = { audio: { deviceId: { exact: audioInputs[1].deviceId } } };
const c3 = { audio: { deviceId: { exact: audioInputs[2].deviceId } } };
getMedia(c1)
.then(() => getMedia(c2))
.then(() => getMedia(c3));
This works fine in Chrome (Version 55.0.2883.87) and I get 3 different streams (C1, C2, C3) with all audioTracks having the expected labels.
But fails with the second and third call to getUserMedia
(C2, C3) in Firefox (50.0.2) with the following error:
According to the documentation for NotReadableErrors
:
Although the user granted permission to use the matching devices, a hardware error occurred at the operating system, browser, or Web page level which prevented access to the device.
(I can however acquire multiple streams with the same constraints without running into that problem.)
Is Firefox behaving as expected here? Since the docs mention a "hardware error"? Is there a different way to acquire multiple streams (with different device constraints)? Or do I have to stop the streams, releasing the devices and then acquiring the new stream?
Thanks for your time.
Currently (Nightly is now 53) Firefox doesn't support multiple active audio input sources.
It's something we're thinking about, but it requires a couple of fairly major changes to our MediaStream plumbing. It's all related to drift - inputs (and outputs) running off different clocks.
We're considering taking an intermediate step towards this by interpreting a request for a new device as an intention to switch devices. That allows us to keep the first open while the prompt for the second is visible and then switch seamlessly. This is relatively low-hanging fruit for the issue in bug 1299324.