Home > AI > IOS > SwiftUI >

VideoPlayer

Example:

struct FreeCourseDetailView: View {
    var videoURL: URL = URL(string: "https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8")!
    var videoPlayer: AVPlayer {
        AVPlayer(url: videoURL)
    }
    
    var body: some View {
        VStack {
            VideoPlayer(player: videoPlayer)

            ScrollView {
                VStack {
                    LiveStreamView()
                }
            }
        }
        .onAppear {
            videoPlayer.play()
        }
        .onDisappear() {
            videoPlayer.pause()
        }
    }
}

Leave a Reply