Reputation: 21
I updated to iOS 12 and the AV Player VC close button don't work anymore. The screen never dismissed, it pause the video instead. This actions was working just fine on previous iOS versions.
Is there any particular reason for this?
EDIT: Added code
guard let movieURL = URL(string: urlStr) else { return }
moviePlayer = AVPlayer(url: movieURL)
self.moviePLayerViewController.player = moviePlayer
moviePLayerViewController.view.frame = vwMainContainer.bounds
moviePLayerViewController.modalTransitionStyle = .crossDissolve
moviePLayerViewController.modalPresentationStyle = .overCurrentContext
present(moviePLayerViewController, animated: true) {
self.moviePlayer?.play()
}
Upvotes: 1
Views: 1413
Reputation: 21
It is resolved now, I just removed the modal presentation style and worked again. I am not sure why this was a problem, if anyone know pleas answer.
guard let movieURL = URL(string: urlStr) else { return }
moviePlayer = AVPlayer(url: movieURL)
self.moviePLayerViewController.player = moviePlayer
moviePLayerViewController.view.frame = vwMainContainer.bounds
present(moviePLayerViewController, animated: true) {
self.moviePlayer?.play()
}
Upvotes: 1
Reputation: 4855
You didn't showed any Code there
Just try the following method It just work perfectly fine for me
//MARK: Play Video At Index Path
func playVideoWith(_ videoURL: URL) {
let player = AVPlayer(url: videoURL)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
playerViewController.view.frame = self.view.frame
self.present(playerViewController, animated: true) {
playerViewController.player?.play()
}
}
Note - Please show code So, we can see where the mistake is else just try above code once and let me know did it helped ?
Upvotes: 2