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