]> git.r.bdr.sh - rbdr/junction/blame_incremental - extension/media.js
Merge branch 'main' of gitlab.com:rbdr/junction into main
[rbdr/junction] / extension / media.js
... / ...
CommitLineData
1'use strict';
2
3const internals = {
4 mediaStream: null
5};
6
7module.exports = {
8 async start() {
9
10 internals.mediaStream = internals.mediaStream || await navigator.mediaDevices.getUserMedia({
11 audio: true
12 });
13
14 return internals.mediaStream;
15 },
16
17 stop() {
18
19 if (!internals.mediaStream) {
20 return;
21 }
22
23 for (const track of internals.mediaStream.getAudioTracks()) {
24 track.stop();
25 }
26
27 internals.mediaStream = null;
28 }
29};