refactor(mediabunny): [PKG-MB-05] own video iterators, frame pools and rendering

This commit is contained in:
Harvey Zhao committed 2026-09-12 19:47:46 +08:00
1 parent 5d0b128483
commit 9d037dcbf9
27 files changed
+3652 -595

No files matched your search

@@ -0,0 +1,33 @@
export default class Poster {
private image: HTMLImageElement | null = null
cancel(): void {
if (!this.image)
return
this.image.onload = null
this.image.onerror = null
this.image = null
}
draw(source: string, current: () => boolean, draw: (image: HTMLImageElement) => void, failure: (error: unknown) => void): void {
this.cancel()
const image = new Image()
this.image = image
image.onload = () => {
if (this.image !== image || !current())
return
this.cancel()
try {
draw(image)
}
catch (error) {
failure(error)
}
}
image.onerror = () => {
if (this.image === image)
this.cancel()
}
image.src = source
}
}