I'm working on a IOS App (With Storyoard). I have a ViewController:
//movieViewController.h
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface movieViewController : UIViewController {
MPMoviePlayerViewController *moviePlayer;
}
@property (strong, nonatomic) MPMoviePlayerViewController *moviePlayer;
-(void) playMovie;
@end
//movieViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self playMovie];
}
-(void)playMovie
{
NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"movie"
ofType:@"mov"];
moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL
fileURLWithPath:videoPath]];
[self presentMoviePlayerViewControllerAnimated:moviePlayer];
}
When I run I see my viewController with a "Loading..." that takes forever.
You should call -prepareToPlay
and/or -play
. Per MPMoviePlayerController
's documentation:
Starting in iOS 5.0, in order to facilitate finer-grained playback control, a new movie player is not automatically prepared to play.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With