Or simply...

import SwiftUI
import AVKit

struct VideoView: View {
let videoURL: URL
@State private var avPlayer = AVPlayer()

var body: some View {
VideoPlayer(player: avPlayer)
.onAppear {
avPlayer.replaceCurrentItem(with: AVPlayerItem(url: videoURL))
avPlayer.play()
}
.onDisappear {
avPlayer.pause()
}
}
}