我已经制作了一段用于播放视频文件的代码。但是当我构建它时,我得到了以下错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[NSURL initFileURLWithPath:]: nil string parameter' First throw call stack: (0x1ed8022 0x11c0cd6 0x1e80a48 0x1e809b9 0xc6553b 0xc654c5 0x2be8 0x1ed9e99 0x32614e 0x3260e6 0x3ccade 0x3ccfa7 0x3cc266 0x34b3c0 0x34b5e6 0x331dc4 0x325634 0x17baef5 0x1eac195 0x1e10ff2 0x1e0f8da 0x1e0ed84 0x1e0ec9b 0x17b97d8 0x17b988a 0x323626 0x29b2 0x2925) 终止调用抛出异常
我已经尝试了很多来修复它,但没有任何效果!你没有解决办法吗?是的,我已经实现了媒体播放器框架!
我编写了以下代码:
-(IBAction)playvideo {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"film" ofType:@"mp4"]];
MPMoviePlayerViewController *playercontroller = [[MPMoviePlayerViewController alloc]
initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:playercontroller];
playercontroller.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[playercontroller.moviePlayer play];
[playercontroller release];
playercontroller = nil;
}