Log in or register to post comments

FlashLight Functionality not working

August 4, 2015 - 6:48am #1

Hi,

 

We are facing Flash light toggle issue.

First we are finding is the device has flash functionality or not using 

hasTorch=CameraDevice.Instance.SetFlashTorchMode(true);

Always it returns false and displaying debug.log as Toggle flash On Failed even my devices has flash lights (checked in 3 devices (asus5,moto g 2 , Alcatel one touch)).

How to toggle Flash ?

can anyone suggest ?

Thanks in advance.

here is piece of code which i have written : 

IEnumerator Start(){

                        hasTorch=CameraDevice.Instance.SetFlashTorchMode(true);
			yield return new WaitForSeconds(0.001f);
			CameraDevice.Instance.SetFlashTorchMode(false);
}
bool torchState=false,hasTouch=false;
void OnGUI(){
if(hasTorch){
					if(GUI.Button(new Rect(0, 0, 140, 130),"Torch"))
					{
						torchState = !torchState;
						CameraDevice.Instance.SetFlashTorchMode(torchState);
						
					}
				}

}

 

 

FlashLight Functionality not working

August 6, 2015 - 9:53pm #2

Finally Its Resolved after some hit and trials.

Given 2 seconds of yield time to check the Flash Light after initializing the QCAR.

IEnumerator Start(){

yield return new WaitForSeconds(2);

hasTorch=CameraDevice.Instance.SetFlashTorchMode(true);
            yield return new WaitForSeconds(0.001f);
            CameraDevice.Instance.SetFlashTorchMode(false);
}

bool torchState=false,hasTouch=false;
void OnGUI(){
if(hasTorch){
                    if(GUI.Button(new Rect(0, 0, 140, 130),"Torch"))
                    {
                        torchState = !torchState;
                        CameraDevice.Instance.SetFlashTorchMode(torchState);
                        
                    }
                }

}

Note: Torch button will display only when your device has Flash.

Log in or register to post comments