ios - Video player in subview using an external source, isn't scaling -


i following video: https://developer.apple.com/videos/play/wwdc2014-503/

and made quick demo , tried add container view , changing subview avplayer showed. added code, although in swift form.

the difference in constructor avplayer in prepareforsegue function wrote following:

playerviewcontroller.player = avplayer(url:      nsurl(string: "http://jplayer.org/video/m4v/big_buck_bunny_trailer.m4v")!) 

the video wide , happens half video player expands past screen ios emulator

i tried playerviewcontroller.view.sizetofit() , on properties video controller i've tried different videogravity settings

(disclaimer: bad ides. avoid them, ios appears impossible)

all of 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 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 screenshot of storyboard. have no idea how help.

enter image description here

i try pass url of video in segue. since in prepareforsegue view of view controller may not initialized , fitted screen autolayout.

so in actual viewcontroller :

override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {     if segue.identifier == "showmovie" {         nslog("im in!!");         //self.view.translatesautoresizingmaskintoconstraints = false         let playerviewcontroller = segue.destinationviewcontroller as! avplayerviewcontroller      //setup player view controller movie     playerviewcontroller.movieurl= "http://jplayer.org/video/m4v/big_buck_bunny_trailer.m4v"  } 

and in viewwillappear of avplayerviewcontroller, use thecode

override func viewwillappear(animated: bool) {         super.viewwillappear(animated);         //setup player view controller movie         playerviewcontroller.player = avplayer(url: nsurl(string: self.movieurl)!)          playerviewcontroller.view.sizetofit() } 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -