mirror of
https://github.com/DIYgod/DPlayer
synced 2024-11-22 18:56:54 +00:00
use timeupdate event
This commit is contained in:
parent
5310ad89aa
commit
0159d92f68
@ -183,7 +183,6 @@ class DPlayer {
|
||||
}).then(() => {
|
||||
});
|
||||
this.timer.enable('loading');
|
||||
this.timer.enable('progress');
|
||||
this.container.classList.remove('dplayer-paused');
|
||||
this.container.classList.add('dplayer-playing');
|
||||
if (this.danmaku) {
|
||||
@ -211,9 +210,7 @@ class DPlayer {
|
||||
|
||||
this.template.playButton.innerHTML = Icons.play;
|
||||
this.video.pause();
|
||||
this.player.container.classList.remove('dplayer-loading'); // TODO
|
||||
this.timer.disable('loading');
|
||||
this.timer.disable('progress');
|
||||
this.container.classList.remove('dplayer-playing');
|
||||
this.container.classList.add('dplayer-paused');
|
||||
if (this.danmaku) {
|
||||
@ -463,6 +460,14 @@ class DPlayer {
|
||||
}
|
||||
});
|
||||
|
||||
this.on('timeupdate', () => {
|
||||
this.bar.set('played', this.video.currentTime / this.video.duration, 'width');
|
||||
const currentTime = utils.secondToTime(this.video.currentTime);
|
||||
if (this.template.ptime.innerHTML !== currentTime) {
|
||||
this.template.ptime.innerHTML = currentTime;
|
||||
}
|
||||
});
|
||||
|
||||
for (let i = 0; i < this.events.videoEvents.length; i++) {
|
||||
video.addEventListener(this.events.videoEvents[i], () => {
|
||||
this.events.trigger(this.events.videoEvents[i]);
|
||||
|
@ -1,5 +1,3 @@
|
||||
import utils from './utils';
|
||||
|
||||
class Timer {
|
||||
constructor (player) {
|
||||
this.player = player;
|
||||
@ -15,7 +13,7 @@ class Timer {
|
||||
}
|
||||
)();
|
||||
|
||||
this.types = ['loading', 'progress', 'info', 'fps'];
|
||||
this.types = ['loading', 'info', 'fps'];
|
||||
|
||||
this.init();
|
||||
}
|
||||
@ -54,18 +52,6 @@ class Timer {
|
||||
}, 100);
|
||||
}
|
||||
|
||||
initprogressChecker () {
|
||||
this.progressChecker = setInterval(() => {
|
||||
if (this.enableprogressChecker) {
|
||||
this.player.bar.set('played', this.player.video.currentTime / this.player.video.duration, 'width');
|
||||
const currentTime = utils.secondToTime(this.player.video.currentTime);
|
||||
if (this.player.template.ptime.innerHTML !== currentTime) {
|
||||
this.player.template.ptime.innerHTML = currentTime;
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
initfpsChecker () {
|
||||
window.requestAnimationFrame(() => {
|
||||
if (this.enablefpsChecker) {
|
||||
|
Loading…
Reference in New Issue
Block a user