fix: loaded bar length (#289)

This commit is contained in:
Hitsuki9 2019-09-25 19:16:13 +08:00 committed by DIYgod
parent 64ac6248e8
commit b3b3c442b8
1 changed files with 4 additions and 0 deletions

View File

@ -149,6 +149,10 @@ class APlayer {
});
// show audio loaded bar: to inform interested parties of progress downloading the media
this.on('canplay', () => {
const percentage = this.audio.buffered.length ? this.audio.buffered.end(this.audio.buffered.length - 1) / this.duration : 0;
this.bar.set('loaded', percentage, 'width');
});
this.on('progress', () => {
const percentage = this.audio.buffered.length ? this.audio.buffered.end(this.audio.buffered.length - 1) / this.duration : 0;
this.bar.set('loaded', percentage, 'width');