I have added a DemoVideo.mp4 in my project and added it to copy resource file. But when i run the app it doesn't play my video. Here is my method.
private func setUpAndPlayVideo() {
guard let videoPath = Bundle.main.path(forResource: "DemoVideo.mp4", ofType: nil) else {
return
}
let videoURL = NSURL(string: videoPath)
let player = AVPlayer(url: videoURL! as URL)
playerViewController = AVPlayerViewController()
playerViewController.player = player
playerViewController.view.frame = self.videoPlayerView.bounds
self.videoPlayerView.addSubview(playerViewController.view)
playerViewController.showsPlaybackControls = false
playerViewController.player?.play()
}
I am invoking this method in viewDidAppear
method but it display this.