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.getTracks()) {
+ track.stop();
+ }
- internals.mediaStream = null;
- },
-};
+ internals.mediaStream = null;
+}