I'm trying to understand how AVPlayer & AVPlayerController works. I'm embedded my player in a view so my player has two mode : little & full screen. When it's little the play/plause button and full screen button work very well. But once it's full screen, the following buttons has no effect : play, pause, done, minimise.
Here is my code :
let videoURL = NSURL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
let avPlayer:AVPLayer = AVPlayer(url: videoURL! as URL)
let playerController = AVPlayerViewController()
playerController.player = avPlayer
playerController.view.backgroundColor = UIColor.racingGreenColor();
playerController.view.translatesAutoresizingMaskIntoConstraints = false;
playerController.showsPlaybackControls = true;
self.middleView.addSubview(playerController.view)
//avPlayer.play()
self.middleView.addConstraint(NSLayoutConstraint(item: playerController.view, attribute: .width, relatedBy: .equal, toItem: self.middleView, attribute: .width, multiplier: 1, constant: 0));
self.middleView.addConstraint(NSLayoutConstraint(item: playerController.view, attribute: .height, relatedBy: .equal, toItem: self.middleView, attribute: .height, multiplier: 1, constant: 0));
self.middleView.addConstraint(NSLayoutConstraint(item: playerController.view, attribute: .centerX, relatedBy: .equal, toItem: self.middleView, attribute: .centerX, multiplier: 1, constant: 0));
self.middleView.addConstraint(NSLayoutConstraint(item: playerController.view, attribute: .centerY, relatedBy: .equal, toItem: self.middleView, attribute: .centerY, multiplier: 1, constant: 0));
Can someone help me please ? Is there a delegate for the 4 methods i'm interested in ?
self.addChildController(playerController);
I've add it on your main view controller and it does the trick for "Done" and "Minimise".