mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 09:41:20 -08:00
截图工具添加销毁方法
This commit is contained in:
1 parent
a47bfb9d31
commit
99614d0717
2 files changed
+45
-21
No files matched your search
@@ -95,6 +95,9 @@ class ArtplayerToolThumbnail extends Emitter {
|
||||
.then(() => {
|
||||
context2D.drawImage(this.video, item.x, item.y, width, height);
|
||||
canvas.toBlob(blob => {
|
||||
if (this.thumbnailUrl) {
|
||||
URL.revokeObjectURL(this.thumbnailUrl);
|
||||
}
|
||||
this.thumbnailUrl = URL.createObjectURL(blob);
|
||||
this.emit('update', this.thumbnailUrl, (index + 1) / number);
|
||||
});
|
||||
@@ -180,6 +183,18 @@ class ArtplayerToolThumbnail extends Emitter {
|
||||
throw new Error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.option.fileInput.removeEventListener('change', this.inputChange);
|
||||
document.body.removeChild(this.video);
|
||||
if (this.videoUrl) {
|
||||
URL.revokeObjectURL(this.videoUrl);
|
||||
}
|
||||
if (this.thumbnailUrl) {
|
||||
URL.revokeObjectURL(this.thumbnailUrl);
|
||||
}
|
||||
this.emit('destroy');
|
||||
}
|
||||
}
|
||||
|
||||
window.ArtplayerToolThumbnail = ArtplayerToolThumbnail;
|
||||
|
||||
Reference in new issue
Block a user