How to Smooth resized video in VideoDisplay component
Posted By :
Rex
| Posted At:
2/10/2011 8:53:15 AM
Tutorial:How to Smooth resized video in VideoDisplay component Flex.
Technology: Adobe AIR, Flash Builder, Adobe Flex, Actionscript 3.0.
Description: If VideoDisplay component is resized or scaled video gets pixelated and also looks rough and untidy. The basic video component inside the VideoDisplay component contains a smoothing property since flash player six which is not exposed publicly in this VideoDisplay component.
Content: Solution to this problem is quite simple . Here we are extending the VideoDisplay component and exposing the smoothing and deblocking property publicly. Deblocking property is used to to enable / disable deblocking filter. Deblocking filter can remove the blocks or artifacts that appear in the video due to excessive compression.
Create a Actionscript 3.0 class and paste the following code.
package
{
import flash.display.DisplayObject;
import mx.controls.VideoDisplay;
import mx.controls.videoClasses.VideoPlayer;
public class SmoothVideoDisplayCom extends VideoDisplay
{
// Public property exposed. Set this property to true to enable smoothing
public var smoothing:Boolean=false;
// Set default value for deblocking filter.
// 0 - automatically enable / disable deblocking filter as per required (recommended)
// 1 - disable deblocking
// 2 - enable deblocking
public var deblocking:int=0;
public function SmoothVideoDisplayCom()
{
super();
}
override public function addChild(child:DisplayObject):DisplayObject
{
// set the value to the video component inside VideoDisplay component
var video:VideoPlayer = VideoPlayer(child);
video.smoothing=smoothing;
video.deblocking=deblocking;
return super.addChild(child);
}
}
}
//The above class can be used in mxml like this
<local:SmoothVideoDisplayCom id="localVideoDisplay" width="320" height="240" x="21" y="0"/>