]> git.r.bdr.sh - rbdr/junction/blame_incremental - extension/media.js
Only send offer on one side
[rbdr/junction] / extension / media.js
... / ...
CommitLineData
1const internals = {
2 mediaStream: null,
3};
4
5export async function startMedia() {
6 internals.mediaStream =
7 internals.mediaStream ||
8 (await navigator.mediaDevices.getUserMedia({
9 audio: true,
10 }));
11
12 return internals.mediaStream;
13}
14
15export async function stopMedia() {
16 if (!internals.mediaStream) {
17 return;
18 }
19
20 for (const track of internals.mediaStream.getAudioTracks()) {
21 track.stop();
22 }
23
24 internals.mediaStream = null;
25}