1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-13 10:32:26 +02:00

fix: Make sure time displays use correctly-formatted time. (#4643)

This commit is contained in:
Pat O'Neill 2017-10-03 12:52:58 -04:00 committed by GitHub
parent f0d9c240fe
commit 20f7fe991f
2 changed files with 32 additions and 2 deletions

View File

@ -35,6 +35,21 @@ class RemainingTimeDisplay extends TimeDisplay {
return 'vjs-remaining-time';
}
/**
* The remaining time display prefixes numbers with a "minus" character.
*
* @param {number} time
* A numeric time, in seconds.
*
* @return {string}
* A formatted time
*
* @private
*/
formatTime_(time) {
return '-' + super.formatTime_(time);
}
/**
* Update remaining time display.
*

View File

@ -66,10 +66,25 @@ class TimeDisplay extends Component {
if (this.textNode_) {
this.contentEl_.removeChild(this.textNode_);
}
this.textNode_ = document.createTextNode(` -${this.formattedTime_ || '0:00'}`);
this.textNode_ = document.createTextNode(this.formattedTime_ || '0:00');
this.contentEl_.appendChild(this.textNode_);
}
/**
* Generates a formatted time for this component to use in display.
*
* @param {number} time
* A numeric time, in seconds.
*
* @return {string}
* A formatted time
*
* @private
*/
formatTime_(time) {
return formatTime(time);
}
/**
* Updates the time display text node if it has what was passed in changed
* the formatted time.
@ -80,7 +95,7 @@ class TimeDisplay extends Component {
* @private
*/
updateFormattedTime_(time) {
const formattedTime = formatTime(time);
const formattedTime = this.formatTime_(time);
if (formattedTime === this.formattedTime_) {
return;