Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17470] IOS: setCameraFlashMode(); getCameraFlashMode(); do not work

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionNot Our Bug
Resolution Date2016-09-28T17:21:20.000+0000
Affected Version/sRelease 3.3.0, Release 5.5.0
Fix Version/sn/a
ComponentsiOS
LabelsTCSupport
ReporterKen
AssigneeHans Knöchel
Created2014-06-01T06:57:07.000+0000
Updated2017-03-29T17:25:02.000+0000

Description

Problem Description

The getFlashMode never work, even after set it.

Test Case

var win1 = Titanium.UI.createWindow({
    title: 'Tab 1',
    backgroundColor: '#fff'
});

var camera = Ti.UI.createButton({
    title: 'Show Camera'
});

camera.addEventListener('click', function() {
    if (Ti.Media.isCameraSupported) {
        Ti.Media.setCameraFlashMode(Ti.Media.CAMERA_FLASH_ON);
        // Ti.Media.setCameraFlashMode(1);
        Ti.API.info(Ti.Media.getCameraFlashMode()); //Note: If we setCameraFlashMode(1) or Ti.Media.CAMERA_FLASH_ON or nay of it it always return 0.
        Titanium.Media.showCamera({
            success: function(event) {
                Ti.API.debug('Our type was: ' + event.mediaType);
                if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
                    var imageView = Ti.UI.createImageView({
                        width: win.width,
                        height: win.height,
                        image: event.media
                    });
                    win1.add(imageView);
                } else {
                    alert("got the wrong type back =" + event.mediaType);
                }
            },
            cancel: function() {
                // called when user cancels taking a picture
            },
            error: function(error) {
                // called when there's an error
                var a = Titanium.UI.createAlertDialog({
                    title: 'Camera'
                });
                if (error.code == Titanium.Media.NO_CAMERA) {
                    a.setMessage('Please run this test on device');
                } else {
                    a.setMessage('Unexpected error: ' + error.code);
                }
                a.show();
            },
            saveToPhotoGallery: true,
            allowEditing: true,
            mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO, Ti.Media.MEDIA_TYPE_PHOTO],
            showControls: true // always use to get the basic facility about camera.
                //overlay:overlayview // do not use overlay to when you want to use the switching facility
        });
    }
});

win1.add(camera);
win1.open();

Steps To Reproduce

- Create a new project - Update app.js file with sample code - And run on iOS device 7.1 - Camera Flash Mode always set to Auto and returns 0.

Expected Result

It’s not working as expected.

Comments

  1. Mauro Parra-Miranda 2014-08-07

    Thanks for your report! The Platform team will set the priority.
  2. Hans Knöchel 2016-09-14

    After a quick look, the implementation looks correct. [~sdarda] or [~mrahman] Can you run a quick test on the device to verify this with 5.5.0.GA?
  3. Shuo Liang 2016-09-23

    [~hansknoechel], I tested the sample code in descirption on iOS 10 with 5.5.0.GA. The setCameraFlashMode() did not work as expected. (always set 0 for flash mode)
  4. Hans Knöchel 2016-09-23

    The reason why it returns 0 is that the internal setter only sets the value if there already is a picker (aka camera) that it can be applied. So I actually think it never worked before. I will schedule further investigation for 6.1.0.
  5. mmeyer 2016-09-24

    It works in iOS 9, but stopped working in iOS10.
  6. Hans Knöchel 2016-09-24

    Let's get this straight: - The cameraFlashMode property is meant to be set and gotten through custom UI that controls it - If you set or get it before opening the camera, no value is applied (since there is no camera to apply it to) and the getter will always return the default value (which is automatic / 0) - In order to get and get it properly, you need to have a custom UI that triggers the flash-mode, since the native controls set it using the internal methods that do not effect the state of this property So the only thing I'm wondering is how this could possibly worked on iOS 9 but not 10. The provided demo-code is a) invalid because of setting and getting the flash-mode before opening the camera and b) cannot trigger the flash-mode, since no custom UI (overlay) is used (see TIDOC-886 for more info). And finally, if it all worked in iOS 9, this is (another) iOS 10 issue: https://forums.developer.apple.com/thread/61467
  7. mmeyer 2016-10-17

    This is an issue on samsung S6 using android 6.0.x. Again if we use OS camera the Flash works. if we use camera overlay flash does not work.
  8. Lee Morris 2017-03-29

    Closing ticket as "Not Our Bug".

JSON Source