ipad视频显示使用as3质量问题

时间:2013-02-06 08:18:49

标签: actionscript-3 ipad camera

我可以使用as3代码在ipad中获得前置摄像头,但视频质量非常低。我使用下面的代码

camera=Camera.getCamera(frontcamIndex);
camera.setQuality (0,90);
user1video.width = 320;
user1video.height =240;
user1video.attachCamera(camera);

1 个答案:

答案 0 :(得分:1)

设置一个关于下面代码的setMode函数。

camera.setMode(320, 240, <#your value#>);

参考以下文档。

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Camera.html#setMode()

我推荐CameraUI。 CameraUI类允许您使用设备上的默认相机应用程序捕获静态图像或视频。

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/CameraUI.html

以下示例使用CameraUI类在设备上启动默认的相机应用程序。当用户拍摄照片时,该示例将图像放在显示列表上。

package  {
 import flash.desktop.NativeApplication;
 import flash.display.Loader;
 import flash.display.MovieClip;
 import flash.display.StageAlign;
 import flash.display.StageScaleMode;
 import flash.events.ErrorEvent;
 import flash.events.Event;
 import flash.events.IOErrorEvent;
 import flash.events.MediaEvent;
 import flash.media.CameraUI;
 import flash.media.MediaPromise;
 import flash.media.MediaType;

     public class CameraUIStillImage extends MovieClip{

          private var deviceCameraApp:CameraUI = new CameraUI();
          private var imageLoader:Loader; 

          public function CameraUIStillImage() {
               this.stage.align = StageAlign.TOP_LEFT;
               this.stage.scaleMode = StageScaleMode.NO_SCALE;

               if( CameraUI.isSupported )
               {
                trace( "Initializing camera..." );

                deviceCameraApp.addEventListener( MediaEvent.COMPLETE, imageCaptured );
                deviceCameraApp.addEventListener( Event.CANCEL, captureCanceled );
                deviceCameraApp.addEventListener( ErrorEvent.ERROR, cameraError );
                deviceCameraApp.launch( MediaType.IMAGE );
               }
               else
               {
                trace( "Camera interface is not supported.");
               }
          }

          private function imageCaptured( event:MediaEvent ):void
          {
               trace( "Media captured..." );

               var imagePromise:MediaPromise = event.data;

               if( imagePromise.isAsync )
               {
                trace( "Asynchronous media promise." );
                imageLoader = new Loader();
                imageLoader.contentLoaderInfo.addEventListener( Event.COMPLETE, asyncImageLoaded );
                imageLoader.addEventListener( IOErrorEvent.IO_ERROR, cameraError );

                imageLoader.loadFilePromise( imagePromise );
               }
               else
               {
                trace( "Synchronous media promise." );
                imageLoader.loadFilePromise( imagePromise );
                showMedia( imageLoader );
               }
          }

          private function captureCanceled( event:Event ):void
          {
               trace( "Media capture canceled." );
               NativeApplication.nativeApplication.exit();
          }

          private function asyncImageLoaded( event:Event ):void
          {
               trace( "Media loaded in memory." );
               showMedia( imageLoader );    
          }

          private function showMedia( loader:Loader ):void
          {
               this.addChild( loader );
          }

          private function cameraError( error:ErrorEvent ):void
          {
               trace( "Error:" + error.text );
               NativeApplication.nativeApplication.exit();
          }
     }
}