mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 02:01:20 -08:00
弹幕池支持异步返回
This commit is contained in:
1 parent
9bd1452030
commit
9d730146c0
5 files changed
+64
-64
No files matched your search
@@ -2,14 +2,21 @@ export default class Danmuku {
|
||||
constructor(art, option = {}) {
|
||||
this.art = art;
|
||||
this.queue = {};
|
||||
this.option = Object.assign({}, Danmuku.option, option);
|
||||
art.constructor.validator(this.option, Danmuku.scheme);
|
||||
this.option.danmus.forEach(this.emit);
|
||||
this.current = [];
|
||||
this.layer = {};
|
||||
this.isStop = false;
|
||||
this.timer = null;
|
||||
this.init();
|
||||
this.option = Object.assign({}, Danmuku.option, option);
|
||||
art.constructor.validator(this.option, Danmuku.scheme);
|
||||
if (typeof this.option.danmus === 'function') {
|
||||
this.option.danmus().then(danmus => {
|
||||
danmus.forEach(this.emit);
|
||||
this.init();
|
||||
});
|
||||
} else {
|
||||
this.option.danmus.forEach(this.emit);
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
||||
static get option() {
|
||||
@@ -24,16 +31,7 @@ export default class Danmuku {
|
||||
|
||||
static get scheme() {
|
||||
return {
|
||||
danmus: {
|
||||
type: 'array',
|
||||
child: {
|
||||
text: 'string',
|
||||
size: 'number',
|
||||
time: 'number',
|
||||
color: 'string',
|
||||
mode: 'number',
|
||||
},
|
||||
},
|
||||
danmus: 'array|function',
|
||||
speed: 'number',
|
||||
opacity: 'number',
|
||||
color: 'string',
|
||||
|
||||
Reference in new issue
Block a user