add ads.init()

This commit is contained in:
Harvey committed 2021-12-23 17:20:32 +08:00
1 parent 558e439261
commit 9f7abe181c
3 files changed
+28 -22

No files matched your search

+13 -11
View File
@@ -1,17 +1,7 @@
export default class Ads {
constructor(art) {
this.art = art;
const { option } = art;
this.index = 0;
this.isEnd = false;
this.playing = false;
this.urlCache = option.url;
if (this.current) {
this.playing = true;
this.play(this.current);
}
this.init();
}
get current() {
@@ -26,6 +16,18 @@ export default class Ads {
return this.art.option.ads[this.index + 1];
}
init() {
this.index = 0;
this.isEnd = false;
this.playing = false;
this.urlCache = this.art.option.url;
if (this.current) {
this.playing = true;
this.play(this.current);
}
}
play(item = {}) {
if (this.isEnd) return;
this.art.player.switchUrl(item.url);