截图工具添加销毁方法

This commit is contained in:
Harvey Zack committed 2018-12-05 19:42:14 +08:00
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;