0Pricing
Swift Academy · Lesson

Embedding Players in SwiftUI

Use VideoPlayer and custom player views.

Video in SwiftUI

SwiftUI provides the VideoPlayer view (from AVKit) to embed media playback declaratively, with built-in controls.

import SwiftUI
import AVKit

The VideoPlayer View

VideoPlayer takes an AVPlayer and renders it with standard transport controls—play, pause, scrubber, fullscreen.

struct PlayerScreen: View {
    let player = AVPlayer(url: URL(string: "https://example.com/v.mp4")!)
    var body: some View {
        VideoPlayer(player: player)
            .frame(height: 240)
    }
}

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