Flashlight + Camera view Problem

Hello guys i am making an online Qr scanner using this pluggin: GitHub - kefniark/UnityBarcodeScanner: Simple Unity Barcode Scanner
the scanner works amazingly, the best i have seen, but on my case, i have an external problem, the LIGHT. i have to do the scan on some places where the ilumination is not good at all.
the proper solution would be using the phone flashlight ( or torch).

void Start () {
		
		anim = menuDesplegable.GetComponent<Animator> ();
	
		DontDestroyOnLoad (gameObject);

		// Create a basic scanner
		BarcodeScanner = new Scanner();
		BarcodeScanner.Camera.Play();

		// Display the camera texture through a RawImage
		BarcodeScanner.OnReady += (sender, arg) => {
			// Set Orientation & Texture
			Image.transform.localEulerAngles = BarcodeScanner.Camera.GetEulerAngles();
			Image.transform.localScale = BarcodeScanner.Camera.GetScale();
			Image.texture = BarcodeScanner.Camera.Texture;

			// Keep Image Aspect Ratio
			var rect = Image.GetComponent<RectTransform>();
			var newHeight = rect.sizeDelta.x * BarcodeScanner.Camera.Height / BarcodeScanner.Camera.Width;
			rect.sizeDelta = new Vector2(rect.sizeDelta.x, newHeight);
		};

		// Track status of the scanner
		BarcodeScanner.StatusChanged += (sender, arg) => {
			TextHeader.text = "Status: " + BarcodeScanner.Status;
		};
	}

	/// <summary>
	/// The Update method from unity need to be propagated to the scanner
	/// </summary>
	void Update()
	{
		if (BarcodeScanner == null)
		{
			return;
		}
		BarcodeScanner.Update();

		//
		if (Input.GetKeyDown ("space")) 
		{

			StartCoroutine ("Getname", "uhgaTV2V22");
			//Getname("bTZ58c4uwg");
		
		}

	}

	#region UI Buttons

	public void ClickStart()
	{
		if (BarcodeScanner == null)
		{
			Log.Warning("No valid camera - Click Start");
			return;
		}

		// Start Scanning
		BarcodeScanner.Scan((barCodeType, barCodeValue) => {
			BarcodeScanner.Stop();
			TextHeader.text = "Found: " + barCodeType + " / " + barCodeValue;

			// Feedback
			Audio.Play();
			// consulta a la base de datos
		//	InsertQR(barCodeValue);
			StartCoroutine ("Getname", barCodeValue);


			#if UNITY_ANDROID || UNITY_IOS
			Handheld.Vibrate();
			#endif

			BarcodeScanner.Stop();
		});
	}

	public void ClickStop()
	{
		if (BarcodeScanner == null)
		{
			Log.Warning("No valid camera - Click Stop");
			return;
		}

		// Stop Scanning
		BarcodeScanner.Stop();
	}

	public void ClickBack()
	{
		// Try to stop the camera before loading another scene
		StartCoroutine(StopCamera(() => {
			SceneManager.LoadScene("Boot");
		}));
	}

this is the code which is working 100% nicely.
If i want to turn on the light, i use this:

	void FL_Start()
	{
		AndroidJavaClass cameraClass = new AndroidJavaClass("android.hardware.Camera");       
		WebCamDevice[] devices = WebCamTexture.devices;

		int camID = 0;
		camera1 = cameraClass.CallStatic<AndroidJavaObject>("open", camID);

		if (camera1 != null)
		{
			AndroidJavaObject cameraParameters = camera1.Call<AndroidJavaObject>("getParameters");
			cameraParameters.Call("setFlashMode", "torch");
			camera1.Call("setParameters", cameraParameters);
			camera1.Call("startPreview");
			Active = true;

		}
		else
		{
			Debug.LogError("[CameraParametersAndroid] Camera not available");
		}

	}

	void OnDestroy()
	{
		FL_Stop();
	}

	void FL_Stop()
	{

		if (camera1 != null)
		{
			camera1.Call("stopPreview");
			camera1.Call("release");
			Active = false;
		}
		else
		{
			Debug.LogError("[CameraParametersAndroid] Camera not available");
		}

	}

	public void Torch()
	{
		
		if (torchOn)
		{
			FL_Stop();
			torchOn = false;
		} 
		else 
		{
			FL_Start();
			torchOn = true;
		}

	}

This code also works 100% nicely for turning on the flashlight. but when i want to use both at same time, once the light is on, the raw image used to display the camera view freezes…

I have been struggling for some time with this… i would love some captain suggestions :smiley:
thanks in advance

Hi, @PelusoWarro Warro I am also getting the same problem. Did you find any solution to this problem? Please help am also stuck on this for many days.

Same problem here, i google it everywhere… no luck

Anybody find a solution to this yet?