mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-11 22:06:17 -08:00
添加首次加载事件
This commit is contained in:
1 parent
cc7e489ff6
commit
dcedb802ee
6 files changed
+34
-37
No files matched your search
@@ -15,13 +15,9 @@ export default class Controls {
|
||||
constructor(art) {
|
||||
this.art = art;
|
||||
this.$map = {};
|
||||
this.isVideoCanplay = false;
|
||||
this.art.on('video:canplay', () => {
|
||||
if (!this.isVideoCanplay) {
|
||||
this.isVideoCanplay = true;
|
||||
this.init();
|
||||
this.mount();
|
||||
}
|
||||
this.art.on('video:firstload', () => {
|
||||
this.init();
|
||||
this.mount();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -41,15 +41,13 @@ export default class Progress {
|
||||
this.$indicator = this.option.$control.querySelector('.art-progress-indicator');
|
||||
this.$tip = this.option.$control.querySelector('.art-progress-tip');
|
||||
|
||||
this.art.on('video:canplay', () => {
|
||||
this.set('loaded', this.getLoaded());
|
||||
highlight.filter(item => !item.disable).forEach(item => {
|
||||
const left = Number(item.time) / $video.duration;
|
||||
append(this.$highlight, `
|
||||
<span data-text="${item.text}" data-time="${item.time}" style="left: ${left * 100}%"></span>
|
||||
`
|
||||
);
|
||||
});
|
||||
this.set('loaded', this.getLoaded());
|
||||
highlight.forEach(item => {
|
||||
const left = Number(item.time) / $video.duration;
|
||||
append(this.$highlight, `
|
||||
<span data-text="${item.text}" data-time="${item.time}" style="left: ${left * 100}%"></span>
|
||||
`
|
||||
);
|
||||
});
|
||||
|
||||
this.art.on('video:progress', () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ export default class Player {
|
||||
this.art = art;
|
||||
this.init();
|
||||
this.eventBind();
|
||||
this.firstLoad = false;
|
||||
}
|
||||
|
||||
init() {
|
||||
@@ -46,6 +47,11 @@ export default class Player {
|
||||
});
|
||||
|
||||
this.art.on('video:canplay', () => {
|
||||
if (!this.firstLoad) {
|
||||
this.firstLoad = true;
|
||||
this.art.emit('video:firstload');
|
||||
}
|
||||
|
||||
this.art.controls.show();
|
||||
this.art.mask.show();
|
||||
this.art.loading.hide();
|
||||
|
||||
Reference in new issue
Block a user