I'm working on an iOS app that has a set of buttons on one view, when one of the buttons is tapped, the app navigates to a new view of a video and should autoplay the video. The video is currently not autoplaying, but will play on tap, my understanding is the video should autoplay with the code below. Any help is appreciated (this is my first time building an iOS app).
let player = AVPlayer(url: URL(fileURLWithPath: Bundle.main.path(forResource: "videoToPlay", ofType: "mp4")!))
VideoPlayer(player: player)
.edgesIgnoreSafeArea(.all)
.onAppear() {
player.play()
}