我正在使用以下代码:
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 对象中。
我要去哪里工作
最佳答案
试试这个:
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];
关于ios - MPMoviePlayerController 不加载电影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13229320/