From 45d9971aca468be195a830d3b15442c0d77223a7 Mon Sep 17 00:00:00 2001 From: Niels Groot Obbink Date: Wed, 29 Aug 2012 16:37:53 +0200 Subject: [PATCH] Fixed embed code width/height problems. --- src/embed.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/embed.js b/src/embed.js index 805f0d92..7b5d4331 100644 --- a/src/embed.js +++ b/src/embed.js @@ -40,22 +40,35 @@ function mistembed(streamname) }; // build HTML for certain kinds of types - function buildPlayer(src, container, width, height) + function buildPlayer(src, container, videowidth, videoheight) { // get the container's width/height - cwidth = parseInt(container.style.width, 10); - cheight = parseInt(container.style.height, 10); + var containerwidth = parseInt(container.scrollWidth, 10); + var containerheight = parseInt(container.scrollHeight, 10); + + if(videowidth > containerwidth && containerwidth > 0) + { + var ratio = videowidth / containerwidth; + + videowidth /= ratio; + videoheight /= ratio; + } + + if(videoheight > containerheight && containerheight > 0) + { + var ratio = videoheight / containerheight; + + videowidth /= ratio; + videoheight /= ratio; + } - // video's max width/height is either the containers width/height (if it's smaller then the video) or the video's size - width = cwidth < width ? cwidth : width; - height = cheight < height ? cheight : height; switch(src.type) { case 'f4v': case 'rtmp': case 'flv': - container.innerHTML = ''; + container.innerHTML = ''; break; } };