我使用以下代码:
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"MovieName" ofType:@"mov"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath isDirectory:NO];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.movieSourceType = MPMovieSourceTypeFile;
moviePlayerController.contentURL = fileURL;
moviePlayerController.fullscreen = YES;
[moviePlayerController prepareToPlay];
[moviePlayerController play];
然而,当执行代码时,会出现电影播放器,但电影永远不会加载。
为了我自己的理智,我添加了以下内容:
NSData *thedata = [[NSData alloc]initWithContentsOfFile:filepath];
我可以验证电影是否存在,因为它已加载到NSData对象中。
我在哪里工作
答案 0 :(得分:2)
尝试这个:
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"MovieName" ofType:@"mov"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath isDirectory:NO];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
moviePlayerController.view.frame = self.view.bounds;
moviePlayerController.movieSourceType = MPMovieSourceTypeFile;
moviePlayerController.fullscreen = YES;
[self.view addSubview:moviePlayerController.view];
[moviePlayerController prepareToPlay];
[moviePlayerController play];