Re: Problem Playing Movie File on iOS
Re: Problem Playing Movie File on iOS
- Subject: Re: Problem Playing Movie File on iOS
- From: Peter Tomaselli <email@hidden>
- Date: Tue, 9 May 2017 11:11:30 -0400
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 <email@hidden> wrote:
>
> > 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
>
_______________________________________________
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