Manually write the async generators so that return() is immediate

This commit is contained in:
Vanilagy
2025-01-02 15:24:38 +01:00
parent 7c5e31a93a
commit 4bef3b6722
4 changed files with 262 additions and 180 deletions
+11 -4
View File
@@ -5,6 +5,7 @@
fileInput.type = 'file';
document.body.append(fileInput);
/*
const encoder = new AudioEncoder({
output: console.log,
error: console.error
@@ -25,6 +26,7 @@
numberOfFrames: 48000
});
encoder.encode(audioData);
*/
fileInput.addEventListener('change', async () => {
const file = fileInput.files[0];
@@ -35,11 +37,16 @@
});
const audioTrack = await input.getPrimaryAudioTrack();
const drain = new Metamuxer.EncodedAudioChunkDrain(audioTrack);
const drain = new Metamuxer.AudioBufferDrain(audioTrack);
for await (const chunk of drain.chunks()) {
console.log(chunk)
}
const chunks = drain.buffers()
const a = chunks.next();
//chunks.return();
console.log(await a)
//console.log("Done")
/*
const videoTrack = await input.getPrimaryVideoTrack();