diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c8e34706..5800559a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG * @gkatsev added issue and PR templates for github ([view](https://github.com/videojs/video.js/pull/3117)) * @Nipoto added fa.json (farsi/persian lang file) ([view](https://github.com/videojs/video.js/pull/3116)) * @forbesjo updated travis to use latest firefox ([view](https://github.com/videojs/video.js/pull/3112)) +* @Naouak updated time display to not change if values do not change ([view](https://github.com/videojs/video.js/pull/3101)) -------------------- diff --git a/src/js/control-bar/time-controls/current-time-display.js b/src/js/control-bar/time-controls/current-time-display.js index 91e769426..ff99fc54e 100644 --- a/src/js/control-bar/time-controls/current-time-display.js +++ b/src/js/control-bar/time-controls/current-time-display.js @@ -55,7 +55,10 @@ class CurrentTimeDisplay extends Component { let time = (this.player_.scrubbing()) ? this.player_.getCache().currentTime : this.player_.currentTime(); let localizedText = this.localize('Current Time'); let formattedTime = formatTime(time, this.player_.duration()); - this.contentEl_.innerHTML = `${localizedText} ${formattedTime}`; + if (formattedTime !== this.formattedTime_) { + this.formattedTime_ = formattedTime; + this.contentEl_.innerHTML = `${localizedText} ${formattedTime}`; + } } } diff --git a/src/js/control-bar/time-controls/duration-display.js b/src/js/control-bar/time-controls/duration-display.js index 0e14bb87c..4350c2e1e 100644 --- a/src/js/control-bar/time-controls/duration-display.js +++ b/src/js/control-bar/time-controls/duration-display.js @@ -58,7 +58,8 @@ class DurationDisplay extends Component { */ updateContent() { let duration = this.player_.duration(); - if (duration) { + if (duration && this.duration_ !== duration) { + this.duration_ = duration; let localizedText = this.localize('Duration Time'); let formattedTime = formatTime(duration); this.contentEl_.innerHTML = `${localizedText} ${formattedTime}`; // label the duration time for screen reader users diff --git a/src/js/control-bar/time-controls/remaining-time-display.js b/src/js/control-bar/time-controls/remaining-time-display.js index 8e5ca35b7..13ed25a1f 100644 --- a/src/js/control-bar/time-controls/remaining-time-display.js +++ b/src/js/control-bar/time-controls/remaining-time-display.js @@ -54,7 +54,10 @@ class RemainingTimeDisplay extends Component { if (this.player_.duration()) { const localizedText = this.localize('Remaining Time'); const formattedTime = formatTime(this.player_.remainingTime()); - this.contentEl_.innerHTML = `${localizedText} -${formattedTime}`; + if (formattedTime !== this.formattedTime_) { + this.formattedTime_ = formattedTime; + this.contentEl_.innerHTML = `${localizedText} -${formattedTime}`; + } } // Allows for smooth scrubbing, when player can't keep up.