fix video player poster aspect ratio

This commit is contained in:
rolux 2013-02-14 12:42:18 +05:30
parent ab06286f8c
commit 4583f7bd77

View file

@ -460,8 +460,15 @@ Ox.VideoPlayer = function(options, self) {
.attr({
src: self.options.poster
})
.appendTo(self.$videoContainer);
self.posterIsVisible = true;
.one({
load: function() {
self.$poster.css(getVideoCSS(
self.$poster[0].width,
self.$poster[0].height
)).appendTo(self.$videoContainer);
self.posterIsVisible = true;
}
});
}
/*
@ -1560,12 +1567,13 @@ Ox.VideoPlayer = function(options, self) {
}, 0);
}
function getVideoCSS() {
function getVideoCSS(videoWidth, videoHeight) {
// optional arguments allow for this function to be used for poster CSS
var playerWidth = self.width,
playerHeight = self.height,
playerRatio = playerWidth / playerHeight,
videoWidth = self.videoWidth,
videoHeight = self.videoHeight,
videoWidth = videoWidth || self.videoWidth,
videoHeight = videoHeight || self.videoHeight,
videoRatio = videoWidth / videoHeight,
videoIsWider = videoRatio > playerRatio,
width, height;