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 AVKitThe 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
- Playing Media with AVPlayer
- Recording Audio
- AVAsset and Composition
- Embedding Players in SwiftUI