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;
}
};