title: Turn on light/torch with front camera
body: <p>I know how to turn on/off the flash light from the back camera. I know how to switch front/back camera. But I don't know how to turn on/off the flash light independently from the active camera. </p>
  
  <p>What I mean: if the active camera is the front one, when I turn on the flash light, it freezes. And when I turn it off, it unfreezes.</p>
  
  <p>My code so far:</p>
  
  <pre><code>var back_cam:AVCaptureDevice?
  for device in devices{
      if (device as AnyObject).hasMediaType(AVMediaTypeVideo) &amp;&amp; (device as AnyObject).position == .back{
          back_cam=device as? AVCaptureDevice
      }
  }
  
  guard let cam=back_cam else {
      print("no back cam?")
      return
  }
  
  if cam.hasTorch{
      do{
          try cam.lockForConfiguration()
              if cam.torchMode == .on{
                  cam.torchMode = .off
              }else{
                  do{
                      try cam.setTorchModeOnWithLevel(1)
                  }catch{
                      print(error)
                  }
              }
              cam.unlockForConfiguration()
          }catch{
              print(error)
          }
      }
  }
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>In case I'm not clear, I'd like to keep the light on, regardless of wether the active camera is the back one or the front one.</p>