feat: createImageBitmap

This commit is contained in:
Harvey Zack committed 2024-09-15 10:56:51 +08:00
1 parent 710f9477f8
commit a74e7bbff4
5 files changed
+15 -13

No files matched your search

+7 -3
View File
@@ -63,9 +63,13 @@ export default function artplayerProxyCanvas() {
async function draw() {
try {
const bitmap = await createImageBitmap(video);
ctx.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
bitmap.close();
if (typeof createImageBitmap !== 'undefined') {
const bitmap = await createImageBitmap(video);
ctx.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
bitmap.close();
} else {
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
}
art.emit('artplayerProxyCanvas:draw', ctx);
} catch (error) {
art.emit('artplayerProxyCanvas:error', error);
@@ -3,8 +3,4 @@ import type Artplayer from 'artplayer';
export = artplayerProxyCanvas;
export as namespace artplayerProxyCanvas;
type Option = (video: HTMLVideoElement, url: String, art: Artplayer) => void;
type Result = HTMLCanvasElement;
declare const artplayerProxyCanvas: (option: Option) => (art: Artplayer) => Result;
declare const artplayerProxyCanvas: () => (art: Artplayer) => HTMLCanvasElement;