diff --git a/packages/artplayer-plugin-danmuku/src/danmuku.js b/packages/artplayer-plugin-danmuku/src/danmuku.js index 9f3c5e27d..cc8dda7c7 100644 --- a/packages/artplayer-plugin-danmuku/src/danmuku.js +++ b/packages/artplayer-plugin-danmuku/src/danmuku.js @@ -33,7 +33,7 @@ export default class Danmuku { art.on('video:waiting', this.stop.bind(this)); art.on('fullscreen', this.reset.bind(this)); art.on('fullscreenWeb', this.reset.bind(this)); - art.on('destroy', this.stop.bind(this)); + art.on('destroy', this.destroy.bind(this)); this.load(); } @@ -443,4 +443,10 @@ export default class Danmuku { return this; } + + destroy() { + this.stop(); + if (this.worker && this.worker.terminate) this.worker.terminate(); + this.art.emit('artplayerPluginDanmuku:destroy'); + } }