6

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.

Bruce
  • 2,230
  • 18
  • 34
  • possible duplicate of [No "Done" button on AVPlayerViewController](http://stackoverflow.com/questions/31036301/no-done-button-on-avplayerviewcontroller) – mattt Aug 04 '15 at 14:37

1 Answers1

8

"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
HardikDG
  • 5,892
  • 2
  • 26
  • 55
rshev
  • 4,086
  • 1
  • 23
  • 32
  • 1
    Thanks. I was trying to nest the AVPlayerViewController as a child of another UIViewController and in that case, I get a run-time warning and the "Done" button doesn't display. – Bruce Aug 05 '15 at 12:11
  • hi @rshev any chance you could help with this question on capturing video? thanks! http://stackoverflow.com/questions/34704032/swift-video-records-at-one-size-but-renders-at-wrong-size – Crashalot Jan 14 '16 at 01:41
  • Is this the same as presenting the view modally per the storyboard? – petrosmm Dec 30 '17 at 00:15