titanium-sdk icon indicating copy to clipboard operation
titanium-sdk copied to clipboard

iOS Ti.Media.showCamera ignores Ti.Media.cameraFlashMode when recording video

Open francesco-lombardo opened this issue 3 years ago • 1 comments

It seems that, in iOS, Ti.Media.cameraFlashMode is ignored when trying to record video (after inspecting the iOS titanium source code, it seems to not be considered at all)

To Reproduce

Ti.Media.cameraFlashMode = Ti.Media.CAMERA_FLASH_OFF; // creating camera in video mode, ignore the flash setting, using always "auto" Ti.Media.showCamera({ mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO], ... });

Expected behavior

The created camera apply the global flash setting (Ti.Media.cameraFlashMode)

Environment

Titanium SDK version: 11.1.1.GA CLI version: 6.1.1

francesco-lombardo avatar Nov 10 '22 14:11 francesco-lombardo

after inspecting the iOS titanium source code, it seems to not be considered at all

It is only set when the camera (=picker) is open, see:

https://github.com/tidev/titanium-sdk/blob/8c034a6160a408399363c0ea951de9c4874d3751/iphone/Classes/MediaModule.m#L535-L552 (same in SDK v11.1.x)

// creating camera in video mode, ignore the flash setting, using always "auto"

Because the initial value is Ti.Media.CAMERA_FLASH_AUTO (= UIImagePickerControllerCameraFlashModeAuto).


To make it work, you simply have to set the flash mode after showCamera():

Ti.Media.showCamera({
   mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO],
   ...
});
Ti.Media.cameraFlashMode = Ti.Media.CAMERA_FLASH_OFF;

It should be explained better in the docs!

hbugdoll avatar Nov 05 '25 09:11 hbugdoll