mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-20 20:21:20 -08:00
chore: Update artplayer-proxy-canvas to support canvas proxy
This commit is contained in:
1 parent
0f60ea53ae
commit
813528f916
4 files changed
+59
-19
No files matched your search
@@ -160,8 +160,24 @@ function artplayerProxyCanvas(callback) {
|
||||
...methods,
|
||||
...prototypes
|
||||
];
|
||||
const originalCanvasProperties = {};
|
||||
[
|
||||
"width",
|
||||
"height"
|
||||
].forEach((prop)=>{
|
||||
originalCanvasProperties[prop] = Object.getOwnPropertyDescriptor(HTMLCanvasElement.prototype, prop);
|
||||
});
|
||||
keys.forEach((key)=>{
|
||||
def(canvas, key, {
|
||||
if (key === "width" || key === "height") def(canvas, key, {
|
||||
get () {
|
||||
return originalCanvasProperties[key].get.call(this);
|
||||
},
|
||||
set (value) {
|
||||
originalCanvasProperties[key].set.call(this, value);
|
||||
video[key] = value;
|
||||
}
|
||||
});
|
||||
else def(canvas, key, {
|
||||
get () {
|
||||
const value = video[key];
|
||||
return typeof value === "function" ? value.bind(video) : value;
|
||||
@@ -215,7 +231,6 @@ function artplayerProxyCanvas(callback) {
|
||||
resize();
|
||||
});
|
||||
art.on("video:play", ()=>{
|
||||
console.log("video:play");
|
||||
cancelAnimationFrame(animationFrame);
|
||||
animationFrame = requestAnimationFrame(drawFrame);
|
||||
});
|
||||
@@ -223,6 +238,10 @@ function artplayerProxyCanvas(callback) {
|
||||
cancelAnimationFrame(animationFrame);
|
||||
});
|
||||
art.on("resize", resize);
|
||||
const destroy = ()=>{
|
||||
cancelAnimationFrame(animationFrame);
|
||||
};
|
||||
art.on("destroy", destroy);
|
||||
if (typeof callback === "function") callback.call(art, video, option.url, art);
|
||||
else video.src = option.url;
|
||||
return canvas;
|
||||
|
||||
Reference in new issue
Block a user