So I have created my vdeo player , but Im havin problems handling different sized videos. How to properly scale videos proportionally?
I get original width and height from metadata object:
private function onMetaData(newMeta:Object):void
{
_height = newMeta.height;
_width = newMeta.width;
scaleProportional();
}
1. Proportional factor
One way to do this is to calculate the proportional factor. It is equal to the width divided by the height:
You can apply that factor to any new width or height you set the video to:
2. Scaling factor
Another way to do it is to find out by which factor to scale the video, then set
scaleXandscaleYinstead ofwidthandheight:3. Proportional display object classes
You can also use the approach in 2. to create a proportional subclass of any
DisplayObjectby overriding the setters forwidth,height,scaleXandscaleYto make all scaling proportional: