Hi,

I’m tying to get a movie to play in iOS. 

I have this in a View Controller. When I run it, it seems to play the file as I 
hear Audio but I get this message in the log:

Warning: Attempt to present <AVPlayerViewController: 0x7f945a814400> on 
<ViewController: 0x7f9458f056e0> whose view is not in the window hierarchy!

I’ve search for help on this but I get hundreds of solutions using all kinds of 
different techniques but none of them work. The Apple Documentation is totally 
useless from what I can see and offers no working solutions to build upon that 
I can find.

Here is the code:

-(void) viewDidLoad
{
AVPlayerViewController*                 myViewController;
AVPlayer*                                       myPlayer;
NSURL*                                          myMovieFileURL;

[super viewDidLoad];

myMovieFileURL = [[NSBundle mainBundle] URLForResource:@"Demo-ENG-EX-001" 
withExtension:@"mp4"];
myPlayer = [[AVPlayer alloc] initWithURL:myMovieFileURL];

myViewController = [[AVPlayerViewController alloc] init];
[self presentViewController:myViewController animated:YES completion:nil];

myViewController.player = myPlayer;
[myPlayer play];
}

I’m guess that I need to add a view to the AVPlayerViewController or vice 
versa? 

Thanks in advance for any help.

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to