]> git.r.bdr.sh - rbdr/junction/blob - extension/media.js
Add media and peer objects
[rbdr/junction] / extension / media.js
1 'use strict';
2
3 const internals = {
4 mediaStream: null
5 };
6
7 module.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 };