0

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

Marcel Colomb
  • 612
  • 5
  • 23

2 Answers2

0

You should never change the camera resolution more then once.

Instead scale the component that you are using to represent the camera output.

Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216
  • Thank you for your answer. But are you sure? There's even a example on the actionscript reference where they doing it: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Camera.html – Marcel Colomb Sep 12 '12 at 14:07
  • Yes, I am! To change the true camera resolution, you need to change the way it communicates with your hardware. If you just wish to change the zoom, do it with the view it is much more cheaper. – Ilya Gazman Sep 12 '12 at 14:09
  • Ok, thank you so I'm going to try a different approach to get the result that I want :) – Marcel Colomb Sep 12 '12 at 14:13
  • I found a why to use setMode() only once. Thank you for your help – Marcel Colomb Sep 13 '12 at 15:17
0

I suggest you check this question How to increase the Quality of the camera using AS3?

I do not think you should null the camera, try just to call cam.setMode()

Community
  • 1
  • 1
Adrian Pirvulescu
  • 4,308
  • 3
  • 30
  • 47