mirror of
https://github.com/videojs/video.js.git
synced 2025-07-07 01:07:13 +02:00
133 lines
4.7 KiB
JavaScript
133 lines
4.7 KiB
JavaScript
![]() |
/**
|
||
|
* Displays the current time
|
||
|
* @param {vjs.Player|Object} player
|
||
|
* @param {Object=} options
|
||
|
* @constructor
|
||
|
*/
|
||
|
vjs.CurrentTimeDisplay = vjs.Component.extend({
|
||
|
/** @constructor */
|
||
|
init: function(player, options){
|
||
|
vjs.Component.call(this, player, options);
|
||
|
|
||
|
player.on('timeupdate', vjs.bind(this, this.updateContent));
|
||
|
}
|
||
|
});
|
||
|
|
||
|
vjs.CurrentTimeDisplay.prototype.createEl = function(){
|
||
|
var el = vjs.Component.prototype.createEl.call(this, 'div', {
|
||
|
className: 'vjs-current-time vjs-time-controls vjs-control'
|
||
|
});
|
||
|
|
||
|
this.content = vjs.createEl('div', {
|
||
|
className: 'vjs-current-time-display',
|
||
|
innerHTML: '<span class="vjs-control-text">Current Time </span>' + '0:00', // label the current time for screen reader users
|
||
|
'aria-live': 'off' // tell screen readers not to automatically read the time as it changes
|
||
|
});
|
||
|
|
||
|
el.appendChild(vjs.createEl('div').appendChild(this.content));
|
||
|
return el;
|
||
|
};
|
||
|
|
||
|
vjs.CurrentTimeDisplay.prototype.updateContent = function(){
|
||
|
// Allows for smooth scrubbing, when player can't keep up.
|
||
|
var time = (this.player_.scrubbing) ? this.player_.getCache().currentTime : this.player_.currentTime();
|
||
|
this.content.innerHTML = '<span class="vjs-control-text">Current Time </span>' + vjs.formatTime(time, this.player_.duration());
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Displays the duration
|
||
|
* @param {vjs.Player|Object} player
|
||
|
* @param {Object=} options
|
||
|
* @constructor
|
||
|
*/
|
||
|
vjs.DurationDisplay = vjs.Component.extend({
|
||
|
/** @constructor */
|
||
|
init: function(player, options){
|
||
|
vjs.Component.call(this, player, options);
|
||
|
|
||
|
player.on('timeupdate', vjs.bind(this, this.updateContent)); // this might need to be changes to 'durationchange' instead of 'timeupdate' eventually, however the durationchange event fires before this.player_.duration() is set, so the value cannot be written out using this method. Once the order of durationchange and this.player_.duration() being set is figured out, this can be updated.
|
||
|
}
|
||
|
});
|
||
|
|
||
|
vjs.DurationDisplay.prototype.createEl = function(){
|
||
|
var el = vjs.Component.prototype.createEl.call(this, 'div', {
|
||
|
className: 'vjs-duration vjs-time-controls vjs-control'
|
||
|
});
|
||
|
|
||
|
this.content = vjs.createEl('div', {
|
||
|
className: 'vjs-duration-display',
|
||
|
innerHTML: '<span class="vjs-control-text">Duration Time </span>' + '0:00', // label the duration time for screen reader users
|
||
|
'aria-live': 'off' // tell screen readers not to automatically read the time as it changes
|
||
|
});
|
||
|
|
||
|
el.appendChild(vjs.createEl('div').appendChild(this.content));
|
||
|
return el;
|
||
|
};
|
||
|
|
||
|
vjs.DurationDisplay.prototype.updateContent = function(){
|
||
|
if (this.player_.duration()) {
|
||
|
this.content.innerHTML = '<span class="vjs-control-text">Duration Time </span>' + vjs.formatTime(this.player_.duration()); // label the duration time for screen reader users
|
||
|
}
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Time Separator (Not used in main skin, but still available, and could be used as a 'spare element')
|
||
|
* @param {vjs.Player|Object} player
|
||
|
* @param {Object=} options
|
||
|
* @constructor
|
||
|
*/
|
||
|
vjs.TimeDivider = vjs.Component.extend({
|
||
|
/** @constructor */
|
||
|
init: function(player, options){
|
||
|
vjs.Component.call(this, player, options);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
vjs.TimeDivider.prototype.createEl = function(){
|
||
|
return vjs.Component.prototype.createEl.call(this, 'div', {
|
||
|
className: 'vjs-time-divider',
|
||
|
innerHTML: '<div><span>/</span></div>'
|
||
|
});
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Displays the time left in the video
|
||
|
* @param {vjs.Player|Object} player
|
||
|
* @param {Object=} options
|
||
|
* @constructor
|
||
|
*/
|
||
|
vjs.RemainingTimeDisplay = vjs.Component.extend({
|
||
|
/** @constructor */
|
||
|
init: function(player, options){
|
||
|
vjs.Component.call(this, player, options);
|
||
|
|
||
|
player.on('timeupdate', vjs.bind(this, this.updateContent));
|
||
|
}
|
||
|
});
|
||
|
|
||
|
vjs.RemainingTimeDisplay.prototype.createEl = function(){
|
||
|
var el = vjs.Component.prototype.createEl.call(this, 'div', {
|
||
|
className: 'vjs-remaining-time vjs-time-controls vjs-control'
|
||
|
});
|
||
|
|
||
|
this.content = vjs.createEl('div', {
|
||
|
className: 'vjs-remaining-time-display',
|
||
|
innerHTML: '<span class="vjs-control-text">Remaining Time </span>' + '-0:00', // label the remaining time for screen reader users
|
||
|
'aria-live': 'off' // tell screen readers not to automatically read the time as it changes
|
||
|
});
|
||
|
|
||
|
el.appendChild(vjs.createEl('div').appendChild(this.content));
|
||
|
return el;
|
||
|
};
|
||
|
|
||
|
vjs.RemainingTimeDisplay.prototype.updateContent = function(){
|
||
|
if (this.player_.duration()) {
|
||
|
if (this.player_.duration()) {
|
||
|
this.content.innerHTML = '<span class="vjs-control-text">Remaining Time </span>' + '-'+ vjs.formatTime(this.player_.remainingTime());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Allows for smooth scrubbing, when player can't keep up.
|
||
|
// var time = (this.player_.scrubbing) ? this.player_.getCache().currentTime : this.player_.currentTime();
|
||
|
// this.content.innerHTML = vjs.formatTime(time, this.player_.duration());
|
||
|
};
|