我正在构建一个必须访问相机的应用,拍摄视频并访问应用中的视频并进行播放。我还需要在录制视频时添加叠加层。我在3个android设备上测试了我的代码huawei ascend g300,nexus 7和galaxey S3,每个都表现不同。
在华为(背面只有相机),它表现得像我想要的那样。视频拍摄后,只有录制的视频和相机ui关闭。
在nexus 7(只有前置摄像头)上显示相机UI一秒钟然后我收到以下消息unfortunately gallery has stopped
在sg s4上(正面和背面有摄像头)摄像头ui启动视频但不会返回我的应用程序。
bellow是我的accessCamera类:
package Classes {
import flash.display.*;
import flash.media.*;
import flash.media.Camera;
import flash.media.CameraUI;
import flash.events.MediaEvent;
import flash.net.*;
public class AccessCamera extends MovieClip {
//-------------- CameraUI-----------------------//
public static var ui = new CameraUI();
public static var video = new Video();
//------------- end Camera UI------------------//
public function AccessCamera() {
// constructor code
trace ("access camera class accessed");
}
public function loggedIn(){
//------------cmaera UI---------------//
if ( CameraUI.isSupported){
ui.launch(MediaType.VIDEO);
ui.addEventListener(MediaEvent.COMPLETE,UICompleteHandler);
}
}
public function UICompleteHandler(event:MediaEvent):void{
var media:MediaPromise = event.data;
trace(media.file.url + " - " + media.relativePath + " - " +media.mediaType);
parent.addChild(video);
var conn:NetConnection = new NetConnection();
conn.connect(null);
//attach a stream to the video-object
var stream:NetStream = new NetStream(conn);
video.attachNetStream(stream);
stream.client = new MobileClient();
//play the stream
stream.play(media.file.url);
}
}
}
//------------- end of package -------------//
class MobileClient {
public function onMetaData(info:Object):void {
trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);
}
public function onCuePoint(info:Object):void {
trace("cuepoint: time=" + info.time + " name=" + info.name + " type=" + info.type);
}
}
有关为什么它在不同设备上表现如此不同的任何线索。