From 4583f7bd77866fd49acf2b1bb58b40de81095108 Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 14 Feb 2013 12:42:18 +0530 Subject: [PATCH] fix video player poster aspect ratio --- source/Ox.UI/js/Video/VideoPlayer.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/source/Ox.UI/js/Video/VideoPlayer.js b/source/Ox.UI/js/Video/VideoPlayer.js index 3a132007..0fb95441 100644 --- a/source/Ox.UI/js/Video/VideoPlayer.js +++ b/source/Ox.UI/js/Video/VideoPlayer.js @@ -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;