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