Diagram of AVPlayer, AVPlayerItem, and AVPlayerViewController
.
Diagram of AVPlayer, AVPlayerItem, and AVPlayerViewController
.
🎥 AVPlayer Architecture Diagram (Visual)
┌────────────────────────────┐
│ AVPlayerViewController │◄────────────┐
│ (UI + Controls Layer) │ │
└────────────────────────────┘ │
▲ │ uses
│ player │
┌────────────────────────────┐ │
│ AVPlayer │◄────────────┘
│ (Playback Logic + Engine) │
└────────────────────────────┘
▲
│ currentItem
┌────────────────────────────┐
│ AVPlayerItem │
│ (Represents a media file) │
└────────────────────────────┘
▲
│ url asset
┌────────────────────────────┐
│ AVAsset / URLAsset │
└────────────────────────────┘
AVPlayer Stack
AVAsset / URLAsset
- What: Represents the actual media file (e.g., MP4, HLS stream).
- Role: Holds metadata (duration, resolution) and the media URL.
2. AVPlayerItem
- What: A playable instance of
AVAsset. - Role: Manages playback state (buffering, errors) for one media file.
3. AVPlayer
- What: The playback engine.
- Role: Controls play/pause/seek and handles timing. Needs an
AVPlayerItemto work.
4. AVPlayerViewController
- What: Ready-made UI with controls (play button, timeline).
- Role: Displays video and sends user commands (e.g., play) to
AVPlayer.
How They Work Together
Flow:
URL → AVAsset → AVPlayerItem → AVPlayer → AVPlayerViewController
Key Points:
- One
AVPlayercan swapAVPlayerItems (e.g., for playlists). AVPlayerViewControlleris optional (useAVPlayerLayerfor custom UI).
let url = URL(string: "https://example.com/video.mp4")!
let asset = AVAsset(url: url)
let playerItem = AVPlayerItem(asset: asset)
let player = AVPlayer(playerItem: playerItem)
let playerVC = AVPlayerViewController()
playerVC.player = player
present(playerVC, animated: true)
This stack balances control (AVPlayer) and convenience (AVPlayerViewController).
메타데이터
- post_id
- cd1880afbbab
- slug
- diagram-of-avplayer-avplayeritem-and-avplayerviewcontroller-cd1880afbbab
- url
- https://medium.com/@nirajpaul2/diagram-of-avplayer-avplayeritem-and-avplayerviewcontroller-cd1880afbbab
- canonical_url
- https://medium.com/@nirajpaul2/diagram-of-avplayer-avplayeritem-and-avplayerviewcontroller-cd1880afbbab
- author_url
- https://medium.com/@nirajpaul2
- status
- ok
- fetched_at
- 2026-06-25 12:15:08