mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-13 15:56:15 -08:00
feat: Refactor danmuku.js to use async/await for emitting danmus
This commit is contained in:
1 parent
69d99cc478
commit
390be821d6
1 file changed
+8
-2
@@ -283,7 +283,13 @@ export default class Danmuku {
|
||||
|
||||
this.queue = []; // 清空实际弹幕队列
|
||||
this.$danmuku.innerText = ''; // 清空弹幕层
|
||||
this.danmus.forEach((danmu) => this.emit(danmu)); // 逐个验证原始弹幕并转换为实际弹幕
|
||||
|
||||
// 逐个验证原始弹幕并转换为实际弹幕
|
||||
for (let index = 0; index < this.danmus.length; index++) {
|
||||
const danmu = this.danmus[index];
|
||||
await this.emit(danmu);
|
||||
}
|
||||
|
||||
this.art.emit('artplayerPluginDanmuku:loaded', this.queue);
|
||||
} catch (error) {
|
||||
this.art.emit('artplayerPluginDanmuku:error', error);
|
||||
@@ -294,7 +300,7 @@ export default class Danmuku {
|
||||
}
|
||||
|
||||
// 把原始弹幕转换为实际弹幕
|
||||
emit(danmu) {
|
||||
async emit(danmu) {
|
||||
const { clamp } = this.utils;
|
||||
|
||||
this.validator(danmu, {
|
||||
|
||||
Reference in new issue
Block a user