1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-04 06:48:49 +02:00

Adjust the font size of the text tracks to make them proportionally larger when switching to fullscreen mode

Signed-off-by: Greg Kraus <gdkraus@ncsu.edu>
This commit is contained in:
Greg Kraus 2013-01-20 07:34:31 -05:00
parent c74c4e2c3a
commit b0f1a8404c

View File

@ -143,6 +143,8 @@ vjs.TextTrack = function(player, options){
this.activeCues_ = [];
this.readyState_ = 0;
this.mode_ = 0;
this.player_.on('fullscreenchange', vjs.bind(this, this.adjustFontSize));
};
goog.inherits(vjs.TextTrack, vjs.Component);
@ -301,6 +303,22 @@ vjs.TextTrack.prototype.mode = function(){
return this.mode_;
};
/**
* Change the font size of the text track to make it larger when playing in fullscreen mode
* and restore it to its normal size when not in fullscreen mode.
*/
vjs.TextTrack.prototype.adjustFontSize = function(){
if (this.player_.isFullScreen) {
// Scale the font by the same factor as increasing the video width to the full screen window width.
// Additionally, multiply that factor by 1.4, which is the default font size for
// the caption track (from the CSS)
this.el_.style.fontSize = screen.width / this.player_.options_.width * 1.4 * 100 + '%';
} else {
// Change the font size of the text track back to its original non-fullscreen size
this.el_.style.fontSize = '';
}
};
/**
* Create basic div to hold cue text
* @return {Element}