2016-04-27 69 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 –