2013-05-02 19:03:29 -07:00
/ * *
* 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'
} ) ;
2014-02-11 17:20:07 -08:00
this . contentEl _ = vjs . createEl ( 'div' , {
2013-05-02 19:03:29 -07:00
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
} ) ;
2014-02-11 17:20:07 -08:00
el . appendChild ( this . contentEl _ ) ;
2013-05-02 19:03:29 -07:00
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 ( ) ;
2014-02-11 17:20:07 -08:00
this . contentEl _ . innerHTML = '<span class="vjs-control-text">Current Time </span>' + vjs . formatTime ( time , this . player _ . duration ( ) ) ;
2013-05-02 19:03:29 -07:00
} ;
/ * *
* 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 ) ;
2014-02-11 17:20:07 -08:00
// this might need to be changed 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.
player . on ( 'timeupdate' , vjs . bind ( this , this . updateContent ) ) ;
2013-05-02 19:03:29 -07:00
}
} ) ;
vjs . DurationDisplay . prototype . createEl = function ( ) {
var el = vjs . Component . prototype . createEl . call ( this , 'div' , {
className : 'vjs-duration vjs-time-controls vjs-control'
} ) ;
2014-02-11 17:20:07 -08:00
this . contentEl _ = vjs . createEl ( 'div' , {
2013-05-02 19:03:29 -07:00
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
} ) ;
2014-02-11 17:20:07 -08:00
el . appendChild ( this . contentEl _ ) ;
2013-05-02 19:03:29 -07:00
return el ;
} ;
vjs . DurationDisplay . prototype . updateContent = function ( ) {
2013-08-26 16:13:54 -07:00
var duration = this . player _ . duration ( ) ;
if ( duration ) {
2014-02-11 17:20:07 -08:00
this . contentEl _ . innerHTML = '<span class="vjs-control-text">Duration Time </span>' + vjs . formatTime ( duration ) ; // label the duration time for screen reader users
2013-05-02 19:03:29 -07:00
}
} ;
/ * *
2013-10-28 18:25:28 -07:00
* The separator between the current time and duration
*
* Can be hidden if it ' s not needed in the design .
*
2013-05-02 19:03:29 -07:00
* @ 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'
} ) ;
2014-02-11 17:20:07 -08:00
this . contentEl _ = vjs . createEl ( 'div' , {
2013-05-02 19:03:29 -07:00
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
} ) ;
2014-02-11 17:20:07 -08:00
el . appendChild ( this . contentEl _ ) ;
2013-05-02 19:03:29 -07:00
return el ;
} ;
vjs . RemainingTimeDisplay . prototype . updateContent = function ( ) {
if ( this . player _ . duration ( ) ) {
2014-02-11 17:20:07 -08:00
this . contentEl _ . innerHTML = '<span class="vjs-control-text">Remaining Time </span>' + '-' + vjs . formatTime ( this . player _ . remainingTime ( ) ) ;
2013-05-02 19:03:29 -07:00
}
// Allows for smooth scrubbing, when player can't keep up.
// var time = (this.player_.scrubbing) ? this.player_.getCache().currentTime : this.player_.currentTime();
2014-02-11 17:20:07 -08:00
// this.contentEl_.innerHTML = vjs.formatTime(time, this.player_.duration());
2013-08-26 16:13:54 -07:00
} ;