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