- (void)viewDidLoad
{
NSString *movieFile1=[[NSBundle mainBundle]pathForResource:@"2" ofType:@"mp4"];
self.moviePlayer=[[MPMoviePlayerController alloc]initWithContentURL:[NSURL fileURLWithPath:movieFile1]];
[super viewDidLoad];
}
我将此视频转为mp4,mov,3gp,m4v,但始终:
线程1:信号SIGABRT
请帮助我!
我认为它应该是格式问题。因为当我使用来自support.apple.com的视频时 ,这段代码有效。那我该怎么办?
答案 0 :(得分:2)
以[super viewDidLoad]为例;到顶部:
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];
}
}