mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 02:43:48 +02:00
Make conversion cancelable
This commit is contained in:
+8
-1
@@ -18,6 +18,12 @@
|
||||
const target = new Metamuxer.BufferTarget();
|
||||
const outputFormat = new Metamuxer.Mp4OutputFormat()
|
||||
|
||||
const abortController = new AbortController();
|
||||
const button = document.createElement('button');
|
||||
button.textContent = 'Cancel';
|
||||
button.onclick = () => abortController.abort();
|
||||
document.body.append(button);
|
||||
|
||||
console.time()
|
||||
const res = await Metamuxer.convert({
|
||||
input: new Metamuxer.Input({
|
||||
@@ -61,7 +67,8 @@
|
||||
},
|
||||
onProgress: (event) => {
|
||||
progress.value = event.completion;
|
||||
}
|
||||
},
|
||||
abortSignal: abortController.signal
|
||||
});
|
||||
console.timeEnd()
|
||||
console.log(res)
|
||||
|
||||
Reference in New Issue
Block a user