I'm developing a video chat application using flex. After some bandwidth check I want to resize the camera resolution based an the result of it.
But every second time I do that the camera frame freezes and I have to kill the flash player and reastart it. The camera basically crashes.
private var camera:Camera;
private function setCameraResolution(width:Number, height:Number):void {
try {
camera = null;
camera = Camera.getCamera();
if (camera == null) {
infoPanel.title = "Error: ";
infoText.text = "No Camera Found";
infoPanel.visible = true;
hideAllControllers();
throw new Error("No Camera Found");
}
camera.setQuality(0, 80);
camera.setKeyFrameInterval(15);
camera.setMode(width, height, 24);
camera.addEventListener(ActivityEvent.ACTIVITY, cameraActivityHandler);
videoCamera.clear();
videoCamera.attachCamera(camera);
} catch (error:Error) {
if (debug) {
ExternalInterface.call('console.log', "Error: " + error.message);
}
}
}
By this point the camera isn't attached to any NetStream. It only happens with some cameras and I'm working with a mac. I checked it on other sites where they change the resolution as well and I never had a problem. It must be my code.
Thank you very much for your help