我正在尝试将视频代码放入我正在使用情节提要的 Xcode 中,但是每次使我崩溃时,这就是错误:
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“ * -[NSURL initFileURLWithPath:]: nil string parameter”*首先抛出调用堆栈:
我将按钮连接到,IBAction
但按下按钮后,应用程序崩溃了
- (IBAction)playMove;
{
NSString *url = [[NSBundle mainBundle]pathForResource:@"skill" ofType:@"flv"];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc]initWithContentURL:[NSURL fileURLWithPath:url]];
theMovie.view.frame = CGRectMake(64, 100, 200, 150);
[self.view addSubview:theMovie.view];
[theMovie play];
}
我的文件name.mp4
很大 480* 360 但那是它崩溃了这是代码
- (IBAction)playMove;
{
NSURL *url =[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"go" ofType:@"mp4"]];
MPMoviePlayerViewController *player = [[MPMoviePlayerViewController alloc]initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:player];
player.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[player.moviePlayer play];
}
并且按钮连接正常我该怎么做才能修复它?
我试图在没有故事板和故事板的情况下使用,但总是崩溃。
这是错误:
NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
*** First throw call stack:
(0x1e0a022 0x1348cd6 0x1db2a48 0x1db29b9 0xb9753b 0xb974c5 0x21dc 0x1e0be99 0x25814e 0x2580e6 0x2feade 0x2fefa7 0x2fe266 0x27d3c0 0x27d5e6 0x263d