]> git.r.bdr.sh - rbdr/junction/blobdiff - extension/media.js
Bump version
[rbdr/junction] / extension / media.js
index 5e83ac74900d17fe6086cd269ae511c7fa8cb19c..416053aa7e65dda87ad70397f643224dc4378fab 100644 (file)
@@ -2,26 +2,24 @@ const internals = {
   mediaStream: null,
 };
 
-export default {
-  async start() {
-    internals.mediaStream =
-      internals.mediaStream ||
-      (await navigator.mediaDevices.getUserMedia({
-        audio: true,
-      }));
+export async function startMedia() {
+  internals.mediaStream =
+    internals.mediaStream ||
+    (await navigator.mediaDevices.getUserMedia({
+      audio: true,
+    }));
 
-    return internals.mediaStream;
-  },
+  return internals.mediaStream;
+}
 
-  stop() {
-    if (!internals.mediaStream) {
-      return;
-    }
+export async function stopMedia() {
+  if (!internals.mediaStream) {
+    return;
+  }
 
-    for (const track of internals.mediaStream.getAudioTracks()) {
-      track.stop();
-    }
+  for (const track of internals.mediaStream.getAudioTracks()) {
+    track.stop();
+  }
 
-    internals.mediaStream = null;
-  },
-};
+  internals.mediaStream = null;
+}