Skip to content

Commit

Permalink
Merge pull request #19 from xqq/master
Browse files Browse the repository at this point in the history
chore: Fix possible buffered range bug in InfoPanel
  • Loading branch information
tsukumijima authored Oct 29, 2023
2 parents dd868a5 + b87d50a commit 2319dde
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ts/info-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class InfoPanel {

// Buffer Remain
if (this.player.video.buffered.length > 0) {
const bufferRemain = this.player.video.buffered.end(0) - this.player.video.currentTime;
const bufferedRangeCount = this.player.video.buffered.length;
const bufferRemain = this.player.video.buffered.end(bufferedRangeCount - 1) - this.player.video.currentTime;
this.template.infoBufferRemain.textContent = `${bufferRemain.toFixed(3)} s`;
} else {
this.template.infoBufferRemain.textContent = 'N/A';
Expand All @@ -81,7 +82,7 @@ class InfoPanel {
const statisticsInfo = player.statisticsInfo as Mpegts.MSEPlayerStatisticsInfo;
this.template.infoMimeType.textContent = mediaInfo.mimeType ?? 'N/A';
this.template.infoVideoFPS.textContent = `${mediaInfo.fps?.toFixed(3) ?? 'N/A'}`;
if (statisticsInfo.speed) {
if (statisticsInfo.speed != undefined) {
this.template.infoDownloadSpeed.textContent = `${statisticsInfo.speed.toFixed(3)} KB/s`;
} else {
this.template.infoDownloadSpeed.textContent = 'N/A';
Expand Down

0 comments on commit 2319dde

Please sign in to comment.