Search code examples
cameraappceleratorappcelerator-titaniumledlight

LED & Camera always ON


I'm trying to open the device camera an activate immediately the LED light of that device (android/iOS).

I've tried the appcelerator ti.media events but didn't work, neither this module: Ti.Light.

Found this on this link activate-iphone-4-led-light

Hey guys!

For the flash stuff you have to check the property: Ti.Media.cameraFlashMode (case sensitive)

To change it you can use Ti.Media.setCameraFlashMode(PARAM) .

PARAM could be: Ti.Media.CAMERA_FLASH_OFF , Ti.Media.CAMERA_FLASH_ON, Ti.Media.CAMERA_FLASH_AUTO

Unfortunately you can’t start the led and use it as a torch, you can only control the camera flash handling (on, off, auto) while taking a photo.

There is any module that allow to use the led light all the time? I just need this while the camera is opened.

UPDATE 1#:

I’m trying to use your ts.camera widget, that have the embed camera and flash methods:

But there is no method switchFlashlight() in “pw.custom.androidcamera” module, this widget works?

UPDATE 2#:

In order to find a workaroud, I've added this flashlight module, and I'm trying to call it before or after showing the camera, but I think that it's not possible to have 2 camera activities at the same time.

This is my index.js file:

if(OS_ANDROID) {

    flash = require('dk.napp.flashlight');

    if(!flash.isFlashLightOn()) flash.turnFlashLightOn();

    camera = require('pw.custom.androidcamera');

    view = camera.createCameraView();
}

I'm getting this error:

[DEBUG] :  CameraViewProxy: Camera not available
[ERROR] :  CameraViewProxy: Camera is null. Make sure
[ERROR] :  CameraViewProxy:     <uses-permission android:name="android.permission.CAMERA" />
[ERROR] :  CameraViewProxy: is in you tiapp.xml file.

This is my tiapp.xml file:

<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.FLASHLIGHT"/>
<uses-feature android:name="android.hardware"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera2"/>
<uses-feature android:name="android.hardware.camera2.params"/>
<uses-feature android:name="android.hardware.camera.flash"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>

Solution

  • These two modules might do the job:

    http://gitt.io/search?q=flash

    Although it could well be that activating the device camera will override the control over the flash light.