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