View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Videos

Abrir menú Cerrar menú
  • Colecciones
  • Todos los videos
  • Información

Más videos

  • Información
  • Código
  • What's new in AVKit

    Learn about enhancements to Picture in Picture and full screen improvements on macOS. Explore the new content source API, and learn how AVPictureInPictureController supports AVSampleBufferDisplayLayer, as well as recommended steps for an app to provide a seamless full screen experience on macOS or in a Mac Catalyst app.

    Recursos

    • AVKit
      • Video HD
      • Video SD

    Videos relacionados

    WWDC21

    • Deliver a great playback experience on tvOS
    • What’s new in AVFoundation

    WWDC19

    • Delivering Intuitive Media Playback with AVKit
  • Buscar este video…
    • 1:16 - New canStartPictureInPictureAutomaticallyFromInline property

      // New property on AVPlayerViewController / AVPictureInPictureController.
      var canStartPictureInPictureAutomaticallyFromInline: Bool { get set }
    • 1:40 - Setting up AVPictureInPictureController with an AVPlayerLayer

      func setupPictureInPicture() {
          // Ensure PiP is supported by current device.
          if AVPictureInPictureController.isPictureInPictureSupported() {
              // Create a new controller, passing the reference to the AVPlayerLayer.
              pictureInPictureController = AVPictureInPictureController(playerLayer: playerLayer)
              pictureInPictureController.delegate = self
              
              // Observe AVPictureInPictureController.isPictureInPicturePossible to update the PiP
              // button’s enabled state.
          } else {
              // PiP isn't supported by the current device. Disable the PiP button.
              pictureInPictureButton.isEnabled = false
          }
      }
    • 2:11 - Starting and stopping picture in picture

      @IBAction func togglePictureInPictureMode(_ sender: UIButton) {
          if pictureInPictureController.isPictureInPictureActive {
              pictureInPictureController.stopPictureInPicture()
          } else {
              pictureInPictureController.startPictureInPicture()
          }
      }
    • 2:56 - AVPictureInPictureSampleBufferPlaybackDelegate

      public protocol AVPictureInPictureSampleBufferPlaybackDelegate: NSObjectProtocol{
      
          // Delegate is responsible for:
          //
          // - Supplying playback state information for PiP UI.
          // - Responding to user input from PiP UI.
      
      }
    • 3:17 - Toggle playback of the video and seek back / ahead 15 seconds

      func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, setPlaying playing: Bool)
      
      func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, skipByInterval skipInterval: CMTime, completion completionHandler: @escaping () -› Void)
    • 3:31 - Provide elapsed time information

      func pictureInPictureControllerTimeRangeForPlayback(_ pictureInPictureController: AVPictureInPictureController) -> CMTimeRange
    • 3:51 - Choose appropriate media variant for render size

      func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, didTransitionToRenderSize newRenderSize: CMVideoDimensions)
    • 4:06 - Update playback state

      func pictureInPictureControllerIsPlaybackPaused(pictureInPictureController: AVPictureInPictureController) -> Bool
    • 6:05 - iOS / MacCatalyst - Persist full screen playback

      func playerViewController(_ playerViewController: AVPlayerViewController, willBeginFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator) {
          coordinator.animate(alongsideTransition: nil) { context in
              // Keep a strong reference to the playerViewController while in full screen.
              self.detachedPlayerViewController = playerViewController
          }
      }
    • 6:38 - iOS / MacCatalyst - Release the playerViewController

      func playerViewController(_ playerViewController: AVPlayerViewController, willEndFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator){
          coordinator.animate(alongsideTransition: nil) { context in
              // Stop keeping the playerViewController alive when transition completes,
              self.detachedPlayerViewController = nil
          }
      }
    • 6:46 - Persist full screen playback on macOS

      func playerViewWillEnterFullScreen(_ playerView: AVPlayerView) {
          // Start keeping the player view alive while it is not in the view hierarchy.
          self.detachedPlayerView = playerView
      }
      
      func playerViewWillExitFullScreen(_ playerView: AVPlayerView) {
          // Stop keeping the player view alive.
          self.detachedPlayerView = nil
      }
    • 6:55 - Restoring UI when exiting full screen

      // Restoring UI when exiting full screen
      
      // iOS / MacCatalyst
      func playerViewControllerRestoreUserInterfaceForFullScreenExit(_ playerViewController: AVPlayerViewController) async -> Bool {
      	// Custom UI restoration logic
      	return true
      }
      
      // macOS
      func playerViewRestoreUserInterfaceForFullScreenExit(_ playerView: AVPlayerView) async -> Bool {
      	// custom UI restore logic here		
      	return true
      }

Developer Footer

  • Videos
  • WWDC21
  • What's new in AVKit
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines