getUserMedia() Stops Audio: MV3 Bug?

119 views
Skip to first unread message

Sentrust

unread,
Jul 24, 2023, 2:54:22 PM7/24/23
to Chromium Extensions
Calling the below stops the audio of the tab (which is expected according to Google's docs):
```
var stream = await navigator.mediaDevices.getUserMedia(
audio: {
    mandatory: {
        chromeMediaSource: "tab",
        chromeMediaSourceId: id,
    },
},
video: false
);
```

However, calling the below does not resume audio like the docs say it should (https://developer.chrome.com/docs/extensions/reference/tabCapture/#preserving-system-audio):
```
const output = new AudioContext();
const source = output.createMediaStreamSource(stream);
source.connect(output.destination);
```

I am calling these in the content script after passing a stream id from a popup. 

Does anyone have any idea how to get the audio playing again after calling getUserMedia like the docs say is possible?

Po Wen Chen (Mayvis)

unread,
Jan 19, 2024, 10:08:32 PM1/19/24
to Chromium Extensions, Sentrust
You just need to play it again.

```
const audio = new Audio()
audio.srcObject = stream
audio.play()
```

Sentrust 在 2023年7月25日 星期二凌晨2:54:22 [UTC+8] 的信中寫道:

Oliver Dunk

unread,
Jan 23, 2024, 11:59:25 AM1/23/24
to Po Wen Chen (Mayvis), Chromium Extensions, Sentrust
In general I've seen some issues when using this in a content script specifically.

If the above suggestion doesn't help, could you try running the code in the popup (if it will remain open) or an offscreen document (if you need to do this in the background)?
Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/4bd61954-7470-4131-be38-b09313c0227cn%40chromium.org.
Reply all
Reply to author
Forward
0 new messages