Problem Playing Movie File on iOS
Problem Playing Movie File on iOS
- Subject: Problem Playing Movie File on iOS
- From: Dave <email@hidden>
- Date: Tue, 9 May 2017 14:31:30 +0200
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 (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