mercredi 9 avril 2014

ActionScript 3 - As3 AIR indésirable retard jusqu'à webcam s'affiche en vidéo - Stack Overflow


I'm trying to attach a camera stream to a video object (Working fine). only problem is, there is a delay up to 4 seconds until the stream shows up. adding an event listener to the video object like VideoEvent.READY or to the camerea object like Event.ACTIVATE seems not to be thrown. (onReady would capture both events with Event type = *). I need to know because while screen is white i want to show a buffer and remove it when webcam data is shown.


What event do i have to register to?


Since it is an air application i do not have a security dialogue in case this would be your first shot ;)


I'm doing like this:


cam = Camera.getCamera();
cam.addEventListener(Event.ACTIVATE, onReady)
if (cam != null) {
cam.setMode(1920, 1080, 25);
cam.setQuality(0, 100);
video = new Video();
addChild(video);
video.attachCamera(cam);

video.addEventListener(VideoEvent.READY, onReady, false, 0, true);
video.width = 1920;
video.height = 1080
}

thank you!




Try something like this:


function cameraActivityHandler(event:ActivityEvent){
var cam:Camera = event.target as Camera;
if(cam.activityLevel > 0){
//Hide loading buffer...
}
}
function initCamera():void{
cam = Camera.getCamera();
cam.addEventListener(ActivityEvent.ACTIVITY, cameraActivityHandler);
if (cam != null) {
cam.setMode(1920, 1080, 25);
cam.setQuality(0, 100);
video = new Video(1920,1080);
addChild(video);
video.attachCamera(cam);

//Show loading buffer...
}
}


I'm trying to attach a camera stream to a video object (Working fine). only problem is, there is a delay up to 4 seconds until the stream shows up. adding an event listener to the video object like VideoEvent.READY or to the camerea object like Event.ACTIVATE seems not to be thrown. (onReady would capture both events with Event type = *). I need to know because while screen is white i want to show a buffer and remove it when webcam data is shown.


What event do i have to register to?


Since it is an air application i do not have a security dialogue in case this would be your first shot ;)


I'm doing like this:


cam = Camera.getCamera();
cam.addEventListener(Event.ACTIVATE, onReady)
if (cam != null) {
cam.setMode(1920, 1080, 25);
cam.setQuality(0, 100);
video = new Video();
addChild(video);
video.attachCamera(cam);

video.addEventListener(VideoEvent.READY, onReady, false, 0, true);
video.width = 1920;
video.height = 1080
}

thank you!



Try something like this:


function cameraActivityHandler(event:ActivityEvent){
var cam:Camera = event.target as Camera;
if(cam.activityLevel > 0){
//Hide loading buffer...
}
}
function initCamera():void{
cam = Camera.getCamera();
cam.addEventListener(ActivityEvent.ACTIVITY, cameraActivityHandler);
if (cam != null) {
cam.setMode(1920, 1080, 25);
cam.setQuality(0, 100);
video = new Video(1920,1080);
addChild(video);
video.attachCamera(cam);

//Show loading buffer...
}
}

0 commentaires:

Enregistrer un commentaire