2013-02-06 34 views
0

我可以使用as3代碼在iPad上獲得前置攝像頭,但視頻質量非常低。我用下面的代碼使用as3質量問題的ipad視頻顯示

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

回答

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(); 
      } 
    } 
} 
+0

感謝您的回覆我已經使用camera.setmode及其工作正常。 – Userseekinganswer