fix subtitles css for 'scale to fill' case
This commit is contained in:
parent
8af214336d
commit
d437d95f96
1 changed files with 27 additions and 18 deletions
|
@ -71,7 +71,7 @@ Ox.VideoPlayer <f> Generic Video Player
|
||||||
out <n> Out point (sec)
|
out <n> Out point (sec)
|
||||||
text <s> Text
|
text <s> Text
|
||||||
tracks <[s]> Track names, like "English" or "Director's Commentary"
|
tracks <[s]> Track names, like "English" or "Director's Commentary"
|
||||||
subtitlesOffset <n|0> adds bottom offset below subtitles in % of height
|
subtitlesOffset <n|0> bottom offset for subtitles in % of video height
|
||||||
subtitlesDefaultTrack <s|'English'> Track name
|
subtitlesDefaultTrack <s|'English'> Track name
|
||||||
subtitlesTrack <s|'English'> Track name
|
subtitlesTrack <s|'English'> Track name
|
||||||
timeline <s> Timeline image URL
|
timeline <s> Timeline image URL
|
||||||
|
@ -1509,15 +1509,7 @@ Ox.VideoPlayer = function(options, self) {
|
||||||
marginLeft: -self.timelineImageWidth + 'px'
|
marginLeft: -self.timelineImageWidth + 'px'
|
||||||
};
|
};
|
||||||
} else if (element == 'subtitle') {
|
} else if (element == 'subtitle') {
|
||||||
css = {
|
css = getSubtitlesCSS();
|
||||||
bottom: (Math.floor(self.height / 16)
|
|
||||||
+ Math.floor(self.options.subtitlesOffset/100 * self.height)
|
|
||||||
+ !!self.controlsBottomAreVisible * 16
|
|
||||||
) + 'px',
|
|
||||||
width: self.width + 'px',
|
|
||||||
fontSize: Math.floor(self.height / 20) + 'px',
|
|
||||||
WebkitTextStroke: (self.height / 1000) + 'px rgb(0, 0, 0)'
|
|
||||||
};
|
|
||||||
} else if (element == 'spaceBottom' || element == 'timeline') {
|
} else if (element == 'spaceBottom' || element == 'timeline') {
|
||||||
css = {
|
css = {
|
||||||
width: self.timelineWidth + 'px'
|
width: self.timelineWidth + 'px'
|
||||||
|
@ -1639,6 +1631,20 @@ Ox.VideoPlayer = function(options, self) {
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSubtitlesCSS() {
|
||||||
|
return {
|
||||||
|
bottom: (
|
||||||
|
Math.floor(self.height / 16)
|
||||||
|
+ Math.floor(self.options.subtitlesOffset / 100 * self.height)
|
||||||
|
+ (self.options.subtitlesOffset ? getVideoCSS().top : 0)
|
||||||
|
+ !!self.controlsBottomAreVisible * 16
|
||||||
|
) + 'px',
|
||||||
|
width: self.width + 'px',
|
||||||
|
fontSize: Math.floor(self.height / 20) + 'px',
|
||||||
|
WebkitTextStroke: (self.height / 1000) + 'px rgb(0, 0, 0)'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function getTimeline() {
|
function getTimeline() {
|
||||||
var $timeline = Ox.SmallVideoTimeline({
|
var $timeline = Ox.SmallVideoTimeline({
|
||||||
//_offset: getTimelineLeft(),
|
//_offset: getTimelineLeft(),
|
||||||
|
@ -1727,6 +1733,16 @@ Ox.VideoPlayer = function(options, self) {
|
||||||
|
|
||||||
function getVideoCSS(videoWidth, videoHeight) {
|
function getVideoCSS(videoWidth, videoHeight) {
|
||||||
// optional arguments allow for this function to be used for poster CSS
|
// optional arguments allow for this function to be used for poster CSS
|
||||||
|
var dimensions = getVideoDimensions(videoWidth, videoHeight);
|
||||||
|
return {
|
||||||
|
left: Math.floor((self.width - dimensions[0]) / 2),
|
||||||
|
top: Math.floor((self.height - dimensions[1]) / 2),
|
||||||
|
width: dimensions[0],
|
||||||
|
height: dimensions[1]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function getVideoDimensions(videoWidth, videoHeight) {
|
||||||
var playerWidth = self.width,
|
var playerWidth = self.width,
|
||||||
playerHeight = self.height,
|
playerHeight = self.height,
|
||||||
playerRatio = playerWidth / playerHeight,
|
playerRatio = playerWidth / playerHeight,
|
||||||
|
@ -1742,14 +1758,7 @@ Ox.VideoPlayer = function(options, self) {
|
||||||
width = videoIsWider ? playerWidth : playerHeight * videoRatio;
|
width = videoIsWider ? playerWidth : playerHeight * videoRatio;
|
||||||
height = videoIsWider ? playerWidth / videoRatio : playerHeight;
|
height = videoIsWider ? playerWidth / videoRatio : playerHeight;
|
||||||
}
|
}
|
||||||
width = Math.round(width);
|
return [Math.round(width), Math.round(height)];
|
||||||
height = Math.round(height);
|
|
||||||
return {
|
|
||||||
left: Math.floor((playerWidth - width) / 2),
|
|
||||||
top: Math.floor((playerHeight - height) / 2),
|
|
||||||
width: width,
|
|
||||||
height: height
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVolumeImage() {
|
function getVolumeImage() {
|
||||||
|
|
Loading…
Reference in a new issue