Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/pwa-audio-recorder/app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

/**
Expand Down Expand Up @@ -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();
}
2 changes: 1 addition & 1 deletion src/pwa-audio-recorder/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

<div class="mdc-card clip clip-recording">
<div class="mdc-card__actions">
<audio src="audio_long16.wav" controls></audio>
<audio id="playback-source" src="audio_long16.wav" controls></audio>
</div>
<div class="mdc-card__content recording-description">audio_long16.wav (Use this to test same-tab echo cancellation)</div>
</div>
Expand Down
Loading