2016-04-27 71 views
0

我试图打开设备摄像头,立即激活该设备(android/iOS)的LED灯。LED和摄像机始终打开

我已经尝试了appcelerator ti.media事件,但没有工作,无论是这个模块:Ti.Light

发现这个这个链接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.

有允许使用LED灯的所有时间任何模块上?相机打开时我只需要这个。

更新1#:

我试图用你的ts.camera部件,具有嵌入摄像头和闪光灯的方法:

但是在“pw.custom.androidcamera”模块中没有方法switchFlashlight(),这个小部件工作KS?

更新2#:

为了找到一个workaroud,我已经添加了这个闪光灯模块,并且我想叫它在展示相机之前或之后,但我认为无法同时进行2个相机活动。

这是我的index.js文件:

if(OS_ANDROID) { 

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

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

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

    view = camera.createCameraView(); 
} 

我得到这个错误:

[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. 

这是我tiapp.xml文件:

<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"/> 

回答

1

这两个模块可能会这样做:

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

虽然很可能激活设备摄像头将无视对闪光灯的控制。

+0

前段时间我尝试了android模块,但没有下载链接,我从git仓库下载了ZIP并创建了一个文件夹:'com.kangacoders.tiflashlight''Library/Application Support/Titanium/modules/android /',并在'com.kangacoders.tiflashlight'文件夹中创建一个包含所有模块文件的文件夹'0.1',但我总是得到这个错误:找不到请求的模块。 问题是Ti.Media上没有TORCH方法 –

+0

我已经下载了2个小部件,但我需要为每个小部件添加一个功能:(https://stackoverflow.com/questions/37032354/edit-a - 钛模块-IOS-机器人)[HTTPS://计算器。com/questions/37032354/edit-a-titanium-module-ios-android] –

+0

@RicardoPereira请关注http://docs.appcelerator.com/platform/latest/#!/guide/Using_a_Module手动安装模块。 TL; DR将ZIP放入项目根目录并将其添加到tiapp.xml –