Playing Media with AVPlayer
Stream and play audio and video assets.
AVFoundation for Media
AVFoundation is Apple’s framework for working with time-based audiovisual media—playback, capture, editing, and export.
The core playback class is AVPlayer.
import AVFoundationAVPlayer and AVPlayerItem
AVPlayer controls playback, while AVPlayerItem represents the media being played and tracks its state. An AVAsset backs the item.
let url = URL(string: "https://example.com/video.mp4")!
let item = AVPlayerItem(url: url)
let player = AVPlayer(playerItem: item)All lessons in this course
- Playing Media with AVPlayer
- Recording Audio
- AVAsset and Composition
- Embedding Players in SwiftUI