Skip to content

Commit

Permalink
fix(player): Formatted time when media has ended and added missing va…
Browse files Browse the repository at this point in the history
…lidation for it to avoid displaying NaN values
  • Loading branch information
rafa8626 committed May 29, 2019
1 parent d50acf3 commit c4c591e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions dist/openplayer.js
Expand Up @@ -6088,8 +6088,10 @@ var Time = function () {
this.events.media.ended = function () {
var el = _this.player.activeElement();

if (_this.player.isMedia() && _this.duration.innerText !== '0:00') {
_this.duration.innerText = time_1.formatTime(el.duration);
var duration = !isNaN(el.duration) ? el.duration : 0;

if (_this.player.isMedia()) {
_this.duration.innerText = time_1.formatTime(duration);
}
};

Expand Down
2 changes: 1 addition & 1 deletion dist/openplayer.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/js/controls/time.ts
Expand Up @@ -146,8 +146,9 @@ class Time implements PlayerComponent {
};
this.events.media.ended = () => {
const el = this.player.activeElement();
if (this.player.isMedia() && this.duration.innerText !== '0:00') {
this.duration.innerText = formatTime(el.duration);
const duration = !isNaN(el.duration) ? el.duration : 0;
if (this.player.isMedia()) {
this.duration.innerText = formatTime(duration);
}
};

Expand Down

0 comments on commit c4c591e

Please sign in to comment.