Re: Problem Playing Movie File on iOS
Re: Problem Playing Movie File on iOS
- Subject: Re: Problem Playing Movie File on iOS
- From: Dave <email@hidden>
- Date: Tue, 9 May 2017 17:03:31 +0200
> On 9 May 2017, at 15:41, Peter Tomaselli <email@hidden> 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 (email@hidden)
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:
This email sent to email@hidden