I was following this video: https://developer.apple.com/videos/play/wwdc2014-503/
And so I made a quick demo and tried add a container View and changing the subview to an avplayer like they showed. Then i added the code, although in swift form.
The difference is in the constructor for the AVPlayer in the prepareForSegue function i wrote the following:
playerViewController.player = AVPlayer(URL:
NSURL(string: "http://jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v")!)
The video is very wide and what happens is half the video player expands past the screen
I tried playerViewController.view.sizeToFit() and on the properties for the video controller i've tried all the different videoGravity settings
(disclaimer: I am very bad with IDEs. I generally avoid them, but with iOS it appears impossible)
All of the code:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showMovie" {
NSLog("im in!!");
//self.view.translatesAutoresizingMaskIntoConstraints = false
let playerViewController = segue.destinationViewController as! AVPlayerViewController
//playerViewController.view.translatesAutoresizingMaskIntoConstraints = false;
//setup player view controller for movie
playerViewController.player = AVPlayer(URL: NSURL(string: "http://jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v")!)
playerViewController.view.sizeToFit()
//playerViewController.showsPlaybackControls = true
//playerViewController.player?.play();
}
}
Here's a screenshot of the storyboard. I have no idea how that could help.