avkit
Create media playback experiences using AVKit. Use when adding video players with AVPlayerViewController, enabling Picture-in-Picture, routing media with AirPlay, using SwiftUI VideoPlayer views, configuring transport controls, displaying subtitles and closed captions, or integrating AVFoundation playback with system UI.
Security Assessment
About avkit
Guidance for building media-playback experiences on Apple platforms with AVKit, the high-level UI layer over AVFoundation, targeting Swift 6.3 and iOS 26+. It covers the system-standard video players, Picture-in-Picture, AirPlay routing, transport controls, playback-speed control, and subtitle and closed-caption display, and it is useful whenever an app needs to present video with system-provided chrome instead of a hand-built player.
Setup guidance covers configuring the audio session with the .playback category, enabling the Audio, AirPlay, and Picture in Picture background modes, and deferring setActive(true) until playback begins so other audio is not interrupted prematurely. For UIKit, AVPlayerViewController is the standard player, presented full screen or embedded inline as a child view controller, and the skill documents its key properties, a delegate for full-screen and PiP lifecycle events, and observing isReadyForDisplay to avoid a black flash. For SwiftUI, the VideoPlayer view wraps the same playback UI and supports an overlay above the video; because it does not expose every AVPlayerViewController property, the guide shows wrapping the controller in a UIViewControllerRepresentable for advanced control such as PiP configuration or playback speed.
Picture-in-Picture is enabled automatically once the app is configured, the device supports it, and the current AVPlayerItem is playable video, since audio-only or unsupported items can make it unavailable. The material lists PiP prerequisites, shows how to restore the UI when PiP stops by calling the delegate completion handler, and points to AVPictureInPictureController for fully custom player UIs. Common-mistakes and review-checklist sections, plus a patterns reference file, round out the guidance.
FAQ
What does AVKit provide?
High-level media playback UI built on AVFoundation: system-standard video players, Picture-in-Picture, AirPlay routing, transport controls, playback-speed control, and subtitle and closed-caption display.
What is required to enable Picture-in-Picture?
The audio session category set to .playback, the Audio, AirPlay, and Picture in Picture background modes enabled, and a ready AVPlayerItem with playable video (not audio-only). For custom players, observe isPictureInPicturePossible.
Can it be used from SwiftUI?
Yes. The VideoPlayer view wraps AVKit's playback UI and supports an overlay, and for advanced control such as PiP configuration, delegate callbacks, or playback speed you wrap AVPlayerViewController in a UIViewControllerRepresentable.
What platform version does it target?
It targets Swift 6.3 and iOS 26+.
How do you present the player inline versus full screen?
For full screen, present the AVPlayerViewController; for inline playback, add it as a child view controller by calling addChild, adding the view with constraints, then didMove(toParent:).
Install avkit
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
dpearson2699/swift-ios-skills