Re: [mediacapture-main] Most browsers lie about how many devices they ask users to share (#648)

Consider the code 

    (async() => {
      navigator.mediaDevices.ondevicechange = e => console.log(e);
      const stream = await navigator.mediaDevices.getUserMedia({
        audio: {
          deviceId: {
            exact: await navigator.mediaDevices.enumerateDevices()
                   .then(devices =>
                       kind, label, groupId
                     }) => label === "Monitor of Built-in Audio Analog Stereo" // Firefox
                             || kind === "audiooutput" && groupId !== "default" // Chromium
      const [audioTrack] = stream.getAudioTracks();
      audioTrack.onmute = audioTrack.onended = e => console.log(e);
      const text = [...Array(10).keys()].join(" ");
      const handleVoicesChanged = async e => {
        const voice = speechSynthesis.getVoices().find(({
        }) => name.includes("English"));
        const utterance = new SpeechSynthesisUtterance(text);
        utterance.voice = voice;
        utterance.pitch = 0.33;
        utterance.rate = 0.1;
        const recorder = new MediaRecorder(stream);
        recorder.ondataavailable = async({
        }) => {
          (new Audio(URL.createObjectURL(data))).play();
        utterance.onend = e => 
          (recorder.state === "recording" && recorder.stop()
          , stream.getAudioTracks()[0].stop());
      speechSynthesis.onvoiceschanged = handleVoicesChanged;
      let voices = speechSynthesis.getVoices();
      if (voices.length) {


which is intended to select only `"audiooutput"`, not `"Microphone"`. 

Firefox 70 outputs the expected result, that is, capturing and recording only audio output, _not_ input from microphone: Meaning _only_ audio output is captured, _not_ microphone input _and_ audio output.

Chromium 80 does not output the expected result. Even where `"audiooutput"` is selected microphone is captured and recorded, not `"audiooutput"`. That is a Chromium bug that is marked `WontFix` ( apparently due to lack of clarity in this specification relevant to the capability to select audio output - not only microphone.

Contrary to the suggestion at `getDisplayMedia()` after testing various approaches, does not provide any means to capture audio output from the system.

Kindly make it clear in this specification that 1) capture of audio output is under the umbrella of this specification and provide an example of the canonical code pattern to achieve that use case per this specification; 2) the user can select `"Monitor of <audio_device>"` at UI prompt and directly in code by use of `applyConstraints()` and directly at `getUserMedia(<constraints>)`; or 3) this specification is _not_ intended to be construed to capture only audio output.

GitHub Notification of comment by guest271314
Please view or discuss this issue at using your GitHub account

Received on Saturday, 7 December 2019 21:00:39 UTC