3 exports.__esModule = true;
5 var _component = require('../../component.js');
7 var _component2 = _interopRequireDefault(_component);
9 var _dom = require('../../utils/dom.js');
11 var Dom = _interopRequireWildcard(_dom);
13 var _formatTime = require('../../utils/format-time.js');
15 var _formatTime2 = _interopRequireDefault(_formatTime);
17 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
19 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
21 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
25 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
26 * @file duration-display.js
31 * Displays the duration
35 var DurationDisplay = function (_Component) {
36 _inherits(DurationDisplay, _Component);
39 * Creates an instance of this class.
41 * @param {Player} player
42 * The `Player` that this class should be attached to.
44 * @param {Object} [options]
45 * The key/value store of player options.
47 function DurationDisplay(player, options) {
48 _classCallCheck(this, DurationDisplay);
50 var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
52 _this.on(player, 'durationchange', _this.updateContent);
54 // Also listen for timeupdate and loadedmetadata because removing those
55 // listeners could have broken dependent applications/libraries. These
56 // can likely be removed for 6.0.
57 _this.on(player, 'timeupdate', _this.updateContent);
58 _this.on(player, 'loadedmetadata', _this.updateContent);
63 * Create the `Component`'s DOM element
66 * The element that was created.
70 DurationDisplay.prototype.createEl = function createEl() {
71 var el = _Component.prototype.createEl.call(this, 'div', {
72 className: 'vjs-duration vjs-time-control vjs-control'
75 this.contentEl_ = Dom.createEl('div', {
76 className: 'vjs-duration-display',
77 // label the duration time for screen reader users
78 innerHTML: '<span class="vjs-control-text">' + this.localize('Duration Time') + '</span> 0:00'
80 // tell screen readers not to automatically read the time as it changes
84 el.appendChild(this.contentEl_);
89 * Update duration time display.
91 * @param {EventTarget~Event} [event]
92 * The `durationchange`, `timeupdate`, or `loadedmetadata` event that caused
93 * this function to be called.
95 * @listens Player#durationchange
96 * @listens Player#timeupdate
97 * @listens Player#loadedmetadata
101 DurationDisplay.prototype.updateContent = function updateContent(event) {
102 var duration = this.player_.duration();
104 if (duration && this.duration_ !== duration) {
105 this.duration_ = duration;
106 var localizedText = this.localize('Duration Time');
107 var formattedTime = (0, _formatTime2['default'])(duration);
109 // label the duration time for screen reader users
110 this.contentEl_.innerHTML = '<span class="vjs-control-text">' + localizedText + '</span> ' + formattedTime;
114 return DurationDisplay;
115 }(_component2['default']);
117 _component2['default'].registerComponent('DurationDisplay', DurationDisplay);
118 exports['default'] = DurationDisplay;