Rathakrishnan Ramasamy
Rathakrishnan Ramasamy

Reputation: 1612

how to use front camera using flex4

I have developed simple camera application for Android mobile using flex 4. The problem is , when I run that application it uses the rear camera. It's not using the front camera. How can I change the camera. I need to use front side camera for this application , kindly help me .

var camera:Camera = Camera.getCamera(cameraIndex.toString());
if (camera)
{
    var ui: UIComponent = new UIComponent();
    var localVideoDisplay: Video = new Video(180, 135);
    localVideoDisplay.attachCamera(camera);
    ui.addChild(localVideoDisplay);                     
    cameraGroup.addChild(ui);
}

this is the code I have used in my application.

Upvotes: 2

Views: 612

Answers (1)

Krishnanunni Jeevan
Krishnanunni Jeevan

Reputation: 1759

try

function getCamera( position:String ):Camera
{
    var camera:Camera;
    var cameraCount:uint = Camera.names.length;
    for ( var i:uint = 0; i < cameraCount; ++i )
    {
        camera = Camera.getCamera( String(i) );
        if ( camera.position == position ) 
            return camera;
    }
    return Camera.getCamera();
}

Use getCamera(CameraPosition.FRONT)

Upvotes: 1

Related Questions