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