ios - iPhone 16 Camera Control and AVCaptureSlider – Is there a way to detect which slider is active? - Stack Overflow

I am following the Apple sample code and trying to add a manual focus lens position slider:@available(

I am following the Apple sample code and trying to add a manual focus lens position slider:

@available(iOS 18.0, *)
private func addCameraControls() {
   
       if !self.session.controls.isEmpty {
           for control in self.session.controls {
               self.session.removeControl(control)
           }
       }
       
       self.cameraControlFocusSlider = nil

       //Focus Slider
       if self.videoDevice!.isLockingFocusWithCustomLensPositionSupported {
           self.cameraControlFocusSlider = AVCaptureSlider("Focus", symbolName: "dot.square", in: 0.0...1.0)
           self.cameraControlFocusSlider!.setActionQueue(self.sessionQueue) { focusValue in
               
             //Do manual focus
               
               
           }
           if self.session.canAddControl(self.cameraControlFocusSlider!) {
               self.session.addControl(self.cameraControlFocusSlider!)
           }
       }
}

So there are these AVCaptureSessionControlsDelegate methods:

   final func sessionControlsDidBecomeActive(_ session: AVCaptureSession) {
        print ("sessionControlsDidBecomeActive")

    }
    
    final func sessionControlsWillEnterFullscreenAppearance(_ session: AVCaptureSession) {
        print ("sessionControlsWillEnterFullscreenAppearance")

    }
    
    final func sessionControlsWillExitFullscreenAppearance(_ session: AVCaptureSession) {
        print ("sessionControlsWillExitFullscreenAppearance")

    }
    
    final func sessionControlsDidBecomeInactive(_ session: AVCaptureSession) {
        print ("sessionControlsDidBecomeInactive")

    }

So when self.cameraControlFocusSlider is presented, I have to show the current value of the lense position. Lens position can change from auto focus and also from manual focus by the user using the app UI. Is there a way to see if self.cameraControlFocusSlider is active or being used?

Please note that I will have more than one AVCaptureSlider in the final code.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744905218a4600214.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信