X-Git-Url: https://git.r.bdr.sh/rbdr/junction/blobdiff_plain/b9a2baf2a7c957089e63844b857e05c07b87c2fb..6717f3d8b71abf255b0e07a5024caa602b5a3d3c:/extension/media.js diff --git a/extension/media.js b/extension/media.js index 5e83ac7..416053a 100644 --- a/extension/media.js +++ b/extension/media.js @@ -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; +}