Reputation: 7
- (void)viewDidLoad
{
NSString *movieFile1=[[NSBundle mainBundle]pathForResource:@"2" ofType:@"mp4"];
self.moviePlayer=[[MPMoviePlayerController alloc]initWithContentURL:[NSURL fileURLWithPath:movieFile1]];
[super viewDidLoad];
}
I turned this video to mp4,mov,3gp,m4v ,but always:
Thread 1:signal SIGABRT
Please help me!
I think it should the problem of format .Because when I use the video from support.apple.com
,this code works. So what should I do?
Upvotes: 0
Views: 334
Reputation: 38249
do this as [super viewDidLoad]; to the top:
NSString *movieFile1=[[NSBundle mainBundle]pathForResource:@"2" ofType:@"mp4"];
if([[NSFileManager defaultManager] fileExistsAtPath:movieFile1])// check whether file exists
{
self.moviePlayer=[[MPMoviePlayerController alloc]initWithContentURL:[NSURL fileURLWithPath:movieFile1]];
if(self.moviePlayer) //reference of movie player created
{
[self.moviePlayer prepareToPlay];
[self.moviePlayer.view setFrame: self.view.bounds];
[self.view addSubview: player.view];
[self.moviePlayer play];
}
}
Upvotes: 2