Bruce
Bruce

Reputation: 2310

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.

Upvotes: 6

Views: 4037

Answers (1)

rshev
rshev

Reputation: 4176

"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

Upvotes: 8

Related Questions