diff --git a/src/pwa-audio-recorder/app.mjs b/src/pwa-audio-recorder/app.mjs index 349072d..b3b8134 100644 --- a/src/pwa-audio-recorder/app.mjs +++ b/src/pwa-audio-recorder/app.mjs @@ -90,6 +90,10 @@ async function init() { const clipContainer = insertClip(); finalizeClip({clipContainer, id, recordingDescription, blob, storage}); } + + if (new URLSearchParams(window.location.search).get('test') === '1') { + runTest(); + } } /** @@ -209,3 +213,28 @@ function visualizeRecording({stream, outlineIndicator, waveformIndicator}) { draw(); } + +async function runTest() { + // 1. Start recording + recordButton.click(); + + // 2. After 10 seconds, start playback + await new Promise((resolve) => setTimeout(resolve, 10000)); + const playbackSource = document.querySelector('#playback-source'); + playbackSource.play(); + + // 3. After 10 seconds, stop recording and stop playback + await new Promise((resolve) => setTimeout(resolve, 10000)); + recordButton.click(); + playbackSource.pause(); + playbackSource.currentTime = 0; + + // 4. Download the recorded audio + await new Promise((resolve) => setTimeout(resolve, 1000)); + const clip = soundClips.firstElementChild; + const audio = clip.querySelector('audio'); + const a = document.createElement('a'); + a.href = audio.src; + a.download = 'recorded_audio.webm'; + a.click(); +} diff --git a/src/pwa-audio-recorder/index.html b/src/pwa-audio-recorder/index.html index 5528b84..bde8427 100644 --- a/src/pwa-audio-recorder/index.html +++ b/src/pwa-audio-recorder/index.html @@ -58,7 +58,7 @@
- +
audio_long16.wav (Use this to test same-tab echo cancellation)