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.
Thanks for your report! The Platform team will set the priority.
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?
[~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)
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.
It works in iOS 9, but stopped working in iOS10.
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/61467This 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.
Closing ticket as "Not Our Bug".