0

我正在尝试在 ios 中播放电影,但我不断收到错误消息。

我的代码:

-(IBAction)playMovie:(id)sender

NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"big-buck-bunny-clip" ofType:@"m4v"];
NSURL    *fileURL    =   [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlaybackComplete:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:moviePlayerController];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
[moviePlayerController play];

}

- (void)moviePlaybackComplete:(NSNotification *)notification

MPMoviePlayerController *moviePlayerController = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
                                                name:MPMoviePlayerPlaybackDidFinishNotification
                                              object:moviePlayerController];
[moviePlayerController.view removeFromSuperview];


[moviePlayerController.view setFrame:CGRectMake(38, 100, 250, 163)];
[self.view addSubview:moviePlayerController.view];
//moviePlayerController.fullscreen = YES;
[moviePlayerController play];

}

错误是:

由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“*** -[NSURL initFileURLWithPath:]: nil string parameter”

4

1 回答 1

0

好的,我明白了..我忘了在构建阶段添加文件...

于 2012-12-21T05:12:32.657 回答