feat: update artplayerProxyCanvas to accept a callback for custom rendering options

This commit is contained in:
Harvey Zack committed 2024-09-17 11:11:52 +08:00
1 parent 92654e911f
commit 1605df2943
4 files changed
+10 -4

No files matched your search

+2 -1
View File
@@ -1,4 +1,4 @@
export default function artplayerProxyCanvas() {
export default function artplayerProxyCanvas(callback) {
return (art) => {
const { constructor } = art;
const { createElement } = constructor.utils;
@@ -66,6 +66,7 @@ export default function artplayerProxyCanvas() {
} else {
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
}
callback && callback(ctx, video);
art.emit('artplayerProxyCanvas:draw', ctx, video);
} catch (error) {
art.emit('artplayerProxyCanvas:error', error);
@@ -3,4 +3,8 @@ import type Artplayer from 'artplayer';
export = artplayerProxyCanvas;
export as namespace artplayerProxyCanvas;
declare const artplayerProxyCanvas: () => (art: Artplayer) => HTMLCanvasElement;
type Option = (ctx: CanvasRenderingContext2D, video: HTMLVideoElement) => void;
type Result = HTMLCanvasElement;
declare const artplayerProxyCanvas: (option: Option) => (art: Artplayer) => Result;