Nifty. I could be wrong, but also: I don't think it's necessary to manually add the AVPlayer's view as a subview of the AVPlayerViewController. Instead, assign the player to your myPlayerViewController.player property before presenting the new controller, and you should automatically get the movie on top where it should be.
In the past I believe I've also put the [myPlayer play] message inside the completion block of presentViewController (in other words, don't start playback until the presentation animation is fully completed). On Tue, May 9, 2017 at 11:03 AM, Dave <d...@looktowindward.com> wrote: > > > On 9 May 2017, at 15:41, Peter Tomaselli <vast.gra...@gmail.com> wrote: > > > > I don't believe you can present a view controller in viewDidLoad. I am > away from my computer, so I can't confirm right now, but I do not believe > the presenting view controller's view is in the view hierarchy yet during > viewDidLoad (exactly as the error message says). > > I realised that a few minutes after posting. I moved it into > viewWillAppear and it sort of works, moved it into viewDidAppear and it > works BUT the code should be: > > -(void) viewDidAppear:(BOOL) theAnimatedFlag > { > NSURL* myMovieFileURL; > AVPlayer* myPlayer; > AVPlayerViewController* myPlayerViewController; > > myMovieFileURL = [[NSBundle mainBundle] > URLForResource:@"OrchidDemo-ENG-EX-001" > withExtension:@"mp4"]; > myPlayer = [[AVPlayer alloc] initWithURL:myMovieFileURL]; > > myPlayerViewController = [[AVPlayerViewController alloc] init]; > [self.pMovieView addSubview:myPlayerViewController.view]; > //*************************************** > > [self presentViewController:myPlayerViewController animated:YES > completion:nil]; > > myPlayerViewController.player = myPlayer; > [myPlayer play]; > } > > All the Best > Dave > > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/vast.grapes%40gmail.com > > This email sent to vast.gra...@gmail.com > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com