]> git.r.bdr.sh - rbdr/junction/blame - extension/media.js
Format extension
[rbdr/junction] / extension / media.js
CommitLineData
e2da0c51 1const internals = {
b9a2baf2 2 mediaStream: null,
e2da0c51
RBR
3};
4
80172072 5export default {
e2da0c51 6 async start() {
b9a2baf2
RBR
7 internals.mediaStream =
8 internals.mediaStream ||
9 (await navigator.mediaDevices.getUserMedia({
10 audio: true,
11 }));
e2da0c51
RBR
12
13 return internals.mediaStream;
14 },
15
16 stop() {
e2da0c51
RBR
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;
b9a2baf2 26 },
e2da0c51 27};