Navigation

    Monaca & Onsen UI
    • Login
    • Search
    • Tags
    • Users
    • Blog
    • Playground
    1. Home
    2. Amirtha
    A
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    Amirtha

    @Amirtha

    0
    Reputation
    1
    Posts
    781
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Amirtha Follow

    Posts made by Amirtha

    • We need a Flashlight toggle switches when barcode scanner on

      Hi all,

      I am developing a Monaca app which uses a barcode scanner plugin to scan. I used https://github.com/phonegap/phonegap-plugin-barcodescanner for implementing barcode scanner and it works fine.

      I implemented the flashlight plugin with https://github.com/EddyVerbruggen/Flashlight-PhoneGap-Plugin.

      The functionality that I need to implement is, the flashlight of the mobile should automatically switch on when the scanning starts and should automatically switch off once the scan is complete.

      I tried the following code:

      <img class="mrg-bt" src="img/qr-scanner.png" onclick="scan();">
      
      function scan(){
        scanlight(true); //switch on flashlight
              window.plugins.barcodeScanner.scan(function(result){
              //scan success code
               scanlight(false);//switch off flashlight
         });
       }
      //flashlight function call
      function scanlight(enable) {
      window.plugins.flashlight.available(function (isAvailable) {
         if (isAvailable) {
            if (enable) {
               window.plugins.flashlight.switchOn(
                  function () { },
                   function () { },  
                   { intensity: 0.3}   
               );
            } else {
               window.plugins.flashlight.switchOff();
            }
         }
      });
      

      }
      The issue is, the functionality is happening quite opposite to my requirement. When I hit the scan button the flashlight gets on and after the camera opens the flashlight goes off and the flashlight gets on once the camera is closed.

      Someone please help me to get rid of this. Thanks in advance.

      posted in Developer Corner
      A
      Amirtha