0Pricing
Swift Academy · Lesson

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 AVFoundation

AVPlayer 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

  1. Playing Media with AVPlayer
  2. Recording Audio
  3. AVAsset and Composition
  4. Embedding Players in SwiftUI
← Back to Swift Academy