Expand my Community achievements bar.

SOLVED

Motorola Xoom (Android) reports both camera positions as "back"

Avatar

Level 2

I'm using this code to try to detect the front facing camera and use it in the WebcamPublisher:

var camera:Camera;

for each ( var camName:String in Camera.names ) {

    camera = Camera.getCamera( camName );

    trace( camName + ":" + String( camera.position ) );

    if ( camera.position == CameraPosition.FRONT ) {

        this.cameraNameIndex = camName;

        break;

    }

}

trace( camName + ":" + String( camera.position ) );

This code is taken from the answer to this post: http://forums.adobe.com/thread/917038

Here is the trace output:

0:back

1:back

1:back

Has anyone experienced this problem with other Android devices?

1 Accepted Solution

Avatar

Correct answer by
Level 1

I just tried your code on my Xoom using the same build settings (AIR 3.1

and FB 4.5.1), and discovered the problem.

You need to set the Android permissions to use the Camera. In your

-app.xml make sure this line is uncommented:

<uses-permission android:name="android.permission.CAMERA"/>

If that line was commented out, then it returned "back" for both

cameras. But if that line is uncommented, then it works properly. With

Android you have to make sure permissions are set for just about

everything (accessing camera, mic, internet, etc.)

Brent

View solution in original post

5 Replies

Avatar

Employee

I didn’t try your code but I think is incorrect.

Camera.getCamera() has the worst interface ever! ☺ It accepts a string parameter, but it’s actually supposed to be a number (0 to Camera.names.length – 1)

So I would try something like this:

for (var i:int = 0; i < Camera.names.length; i++) {

var camera:Camera = Camera.getCamera(i.toString());

trace(I + “: “ + Camera.names[i] + “, “ + camera.position);

}

With your code probably every non-numeric string gets converted to “0” and you always pick the first camera (back).

Avatar

Level 1

Make sure you're compiling against AIR 3.0+ or higher, since front

camera support for Android isn't available in older versions of AIR.

Also there's a new Camera.position property that you check to guarantee

you're asking for the Front camera (if it's supported).

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Camera.html#position

Brent

Avatar

Level 2

I'm compiling against AIR 3.1.  I am using Flash Builder 4.5.1 Premium, debugging on the Xoom device via USB.

I believe this is a bug.  The following code reports both camera positions as "back":

var camera:Camera;

camera = Camera.getCamera( "0" );               

trace( camera.name + ":" + camera.position );           

camera = Camera.getCamera( "1" );               

trace( camera.name + ":" + camera.position );

Outputs:

0:back

1:back

I'm new to Flash development: should I be reporting bugs like this in this forum or is there a separate bug tracker I should use?

Thanks.

Avatar

Correct answer by
Level 1

I just tried your code on my Xoom using the same build settings (AIR 3.1

and FB 4.5.1), and discovered the problem.

You need to set the Android permissions to use the Camera. In your

-app.xml make sure this line is uncommented:

<uses-permission android:name="android.permission.CAMERA"/>

If that line was commented out, then it returned "back" for both

cameras. But if that line is uncommented, then it works properly. With

Android you have to make sure permissions are set for just about

everything (accessing camera, mic, internet, etc.)

Brent

Avatar

Level 2

Thanks Brent!!  Problem fixed.