- 1 :
/**
- 2 :
* @file current-time-display.js
- 3 :
*/
- 4 :
import TimeDisplay from './time-display';
- 5 :
import Component from '../../component.js';
- 6 :
- 7 :
/**
- 8 :
* Displays the current time
- 9 :
*
- 10 :
* @extends Component
- 11 :
*/
- 12 :
class CurrentTimeDisplay extends TimeDisplay {
- 13 :
- 14 :
/**
- 15 :
* Builds the default DOM `className`.
- 16 :
*
- 17 :
* @return {string}
- 18 :
* The DOM `className` for this object.
- 19 :
*/
- 20 :
buildCSSClass() {
- 21 :
return 'vjs-current-time';
- 22 :
}
- 23 :
- 24 :
/**
- 25 :
* Update current time display
- 26 :
*
- 27 :
* @param {Event} [event]
- 28 :
* The `timeupdate` event that caused this function to run.
- 29 :
*
- 30 :
* @listens Player#timeupdate
- 31 :
*/
- 32 :
updateContent(event) {
- 33 :
// Allows for smooth scrubbing, when player can't keep up.
- 34 :
let time;
- 35 :
- 36 :
if (this.player_.ended()) {
- 37 :
time = this.player_.duration();
- 38 :
} else {
- 39 :
time = (this.player_.scrubbing()) ? this.player_.getCache().currentTime : this.player_.currentTime();
- 40 :
}
- 41 :
- 42 :
this.updateTextNode_(time);
- 43 :
}
- 44 :
}
- 45 :
- 46 :
/**
- 47 :
* The text that is added to the `CurrentTimeDisplay` for screen reader users.
- 48 :
*
- 49 :
* @type {string}
- 50 :
* @private
- 51 :
*/
- 52 :
CurrentTimeDisplay.prototype.labelText_ = 'Current Time';
- 53 :
- 54 :
/**
- 55 :
* The text that should display over the `CurrentTimeDisplay`s controls. Added to for localization.
- 56 :
*
- 57 :
* @type {string}
- 58 :
* @protected
- 59 :
*
- 60 :
* @deprecated in v7; controlText_ is not used in non-active display Components
- 61 :
*/
- 62 :
CurrentTimeDisplay.prototype.controlText_ = 'Current Time';
- 63 :
- 64 :
Component.registerComponent('CurrentTimeDisplay', CurrentTimeDisplay);
- 65 :
export default CurrentTimeDisplay;