ios - MPMoviePlayerController 不加载电影

标签 ios mpmovieplayercontroller quicktime

我正在使用以下代码:

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/

相关文章:

ios - 在Windows中无法以编程方式在iOS中录制的音频无法播放

iOS - 检测电影已完成

objective-c - 尝试使用 MPMoviePlayerController 播放视频,只获取音频

macos - Chrome 需要 quicktime,但 OS X 说它是内置的。如何在 chrome 中播放 quicktime 电影?

ios - 如何使用 fmdb 为 native trigger.IO 插件构建 native ios 数据库。

iphone - 在我的 iPhone 应用程序中将数据发布到服务器上

audio - AVAssetWriter实时处理文件中的音频和AVCaptureSession中的音频

iphone - 您可以使用 Safari iPhone 在页面内播放 <video> 吗?

ios - UIButton -setTitle : forState: doesn't seem to work

ios - 仅支持纵向应用程序中视频播放器 View Controller 的所有方向