-
Prenez en charge la fonctionnalité Center Stage de la caméra avant dans votre app iOS
Optimisez votre app caméra iOS avec Center Stage en utilisant les API AVCapture avec la caméra avant sur iPhone 17, iPhone 17 Pro et iPhone Air. Découvrez comment les API offrent des options de zoom et de rotation, pour des moyens plus flexibles de cadrer des selfies et des vidéos, et pour inclure automatiquement tout le monde sur une photo de groupe. Intégrez la fonctionnalité Center Stage pour les appels vidéo afin d'ajuster automatiquement le cadrage, de sorte que vous restiez au centre lors des réunions virtuelles et des appels FaceTime. Et apprenez à stabiliser votre vidéo pour une visioconférence en temps réel.
Chapitres
- 0:00 - Introduction
- 1:07 - Caméra frontale Center Stage
- 2:09 - Center Stage pour les photos
- 3:09 - Configuration de la session de capture
- 3:56 - Rapport d’aspect dynamique
- 6:47 - Moniteur de cadrage intelligent
- 9:24 - Compensation d’orientation du capteur
- 11:53 - Center Stage pour les enregistrements vidéo
- 13:16 - Center Stage pour les appels vidéo
Ressources
- Supporting Center Stage front camera in your iOS app
- AVCam: Building a camera app
- AVFoundation
- Capture setup
Vidéos connexes
WWDC26
WWDC23
WWDC21
-
Rechercher dans cette vidéo…
-
-
5:29 - Support dynamic aspect ratio
// Select the Center Stage front camera import AVFoundation let deviceDiscoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInUltraWideCamera], mediaType: .video, position: .front) guard let camera = deviceDiscoverySession.devices.first else { print("Failed to find the capture device") return } // Find a format that supports the 4x3 aspect ratio for format in camera.formats { if format.supportedDynamicAspectRatios.contains(.ratio4x3) { try! camera.lockForConfiguration() camera.activeFormat = format camera.unlockForConfiguration() break } } // Set dynamic aspect ratio try! camera.lockForConfiguration() let timestamp = try! await camera.setDynamicAspectRatio(.ratio4x3) print("Applied dynamic aspect ratio at timestamp: \(timestamp)") camera.unlockForConfiguration() -
7:39 - Support smart framing monitor
// Find a format that supports smart framing import AVFoundation for format in camera.formats { if format.isSmartFramingSupported { try! camera.lockForConfiguration() camera.activeFormat = format camera.unlockForConfiguration() break } } // Configure the smart framing monitor let monitor = camera.smartFramingMonitor! try! camera.lockForConfiguration() monitor.enabledFramings = monitor.supportedFramings camera.unlockForConfiguration() // Monitor framing recommendations observation = monitor.observe(\.recommendedFraming, options: [.new,]) { monitor, change in if let framing = monitor.recommendedFraming { Task { try! camera.lockForConfiguration() try! await camera.setDynamicAspectRatio(framing.aspectRatio) camera.videoZoomFactor = CGFloat(framing.zoomFactor) camera.unlockForConfiguration() } } } // Start the smart framing monitor try! monitor.startMonitoring() // Stop the smart framing monitor observation?.invalidate() observation = nil monitor.stopMonitoring() -
14:44 - Support Center Stage for video calls
// Find a format that supports Center Stage import AVFoundation for format in camera.formats { if format.isCenterStageSupported { try! camera.lockForConfiguration() camera.activeFormat = format camera.unlockForConfiguration() break } } // Turn on Center Stage AVCaptureDevice.centerStageControlMode = .cooperative AVCaptureDevice.isCenterStageEnabled = true
-