feat: 重命名渲染函数,优化绘制逻辑,增加绘制事件的日志输出

This commit is contained in:
Harvey Zack committed 2024-09-14 23:33:30 +08:00
1 parent f867a97032
commit d4a868621f
3 files changed
+15 -13

No files matched your search

+7 -6
View File
@@ -53,21 +53,22 @@ export default function artplayerProxyCanvas(callback) {
}
});
const render = async () => {
const draw = async () => {
const bitmap = await createImageBitmap(video);
ctx.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
bitmap.close();
art.emit('artplayerProxyCanvas:draw', ctx);
};
const drawFrame = async () => {
const animation = async () => {
try {
console.log('1');
await render();
await draw();
console.log('2');
} catch (error) {
console.error('Error drawing video frame:', error);
}
animationFrame = requestAnimationFrame(drawFrame);
animationFrame = requestAnimationFrame(animation);
};
const resize = () => {
@@ -111,7 +112,7 @@ export default function artplayerProxyCanvas(callback) {
art.on('video:play', () => {
console.log('video:play');
cancelAnimationFrame(animationFrame);
animationFrame = requestAnimationFrame(drawFrame);
animationFrame = requestAnimationFrame(animation);
});
art.on('video:pause', () => {
@@ -121,7 +122,7 @@ export default function artplayerProxyCanvas(callback) {
art.on('resize', () => {
resize();
render();
draw();
});
art.on('destroy', () => {