0

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

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

1 回答 1

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();
          }
     }
}
于 2013-02-06T08:54:57.027 回答