Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift AVPlayer has no done button

Using iOS 8.4, I have created an AVPlayerViewController with and AVPlayer. The video controls appear as expected and the video plays, but there is no "Done" button and xCode crashes whenever I try to lay one on the ViewController at the top of the view. An example I saw: Video Playback clearly shows a "Done" button on the upper left of the screen.

Do AVPlayerViewController and AVPlayer support a "Done" button? Is it possible to add one?

The existing answer suggested by the comment included Objective-C code.

like image 668
Bruce Avatar asked Aug 04 '15 14:08

Bruce


1 Answers

"Done" button is present and working if doing this way:

    let playerVC = AVPlayerViewController()
    playerVC.player = AVPlayer(URL: NSURL(string: "http://www.ebookfrenzy.com/ios_book/movie/movie.mov")!)
    self.presentViewController(playerVC, animated: true, completion: nil)

Swift 3:

self.showDetailViewController(playerVC, sender: self) 
// presentViewController is deprecated
like image 182
rshev Avatar answered Oct 30 '22 07:10

rshev