Skip to main content

Live captions in SwiftUI

Captions should be provided in real-time to enable users to understand what is being said in live videos. The challenge with live captions is both organizational and technical. A captioner must be present who can provide live captions for the video by using suitable software.

Live captions - SwiftUI

In SwiftUI, AVPlayer has built-in support for live video with captions. Users can automatically turn on captions via System Preferences. The easiest way to stream a live video is through VideoPlayer view.

guard let url = URL(string: "https://appt.org/live-video") else { 
return
}

let player = AVPlayer(url: url)

VideoPlayer(player: player)
// for a player on fullscreen
.edgesIgnoringSafeArea(.all)
.onAppear {
player.play()
}