Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3364] How to open front camera first in iphone4 instead of backside camera?

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionDuplicate
Resolution Date2011-11-03T15:19:03.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
Reporterbhavyahmehta
AssigneeReggie Seagraves
Created2011-04-15T03:43:18.000+0000
Updated2017-03-09T22:49:18.000+0000

Description

I use following code:

       Ti.Media.switchCamera(Ti.Media.CAMERA_REAR);

    if (Ti.Media.camera == Ti.Media.CAMERA_REAR)
    {
        Ti.Media.switchCamera(Ti.Media.CAMERA_FRONT);
    }

but it does not help me to open front camera first instead of back camera.

I get -- [ERROR] invalid state. in -[MediaModule switchCamera:] (MediaModule.m:644)

please help me to solve this issue.

Comments

  1. Andrew Skinner 2011-04-15

    I believe the "invalid state" error only happens in the simulator, since there is no camera to switch. However, I can confirm that switchCamera does nothing on the device either.

  2. Andrew Skinner 2011-04-15

    So, a couple of bugs lead to switchCamera not working quite right.

    One, the constants for CAMERA_FRONT and CAMERA_REAR are flipped (so FRONT refers to Rear, and REAR refers to FRONT).

    Lines 451-452 of MediaModule.m should be:

       MAKE_SYSTEM_PROP(CAMERA_FRONT,UIImagePickerControllerCameraDeviceFront);
       MAKE_SYSTEM_PROP(CAMERA_REAR,UIImagePickerControllerCameraDeviceRear);
       

    Also, the code calls a setCameraDevice function, which does not exist. Instead I think you need to set the cameraDevice property of the picker.

    So, line 669 of MediaModule.m should be:

       picker.cameraDevice = [TiUtils intValue:args];
       

    Hopefully easy fixes! Hope to see them in soon.

  3. Dawson Toth 2011-11-03

    Duplicates. The root issue is front and back are switched in the module.
  4. Lee Morris 2017-03-09

    Closing ticket as duplicate.

JSON Source