objective-c - 在 ios 6 中播放视频

标签 objective-c ios ios6

我想在 ios 6 中播放视频。我使用的是 Xcode 4.5。我在下面编写代码但出现错误

 Test Demo[736:14003] [MPAVController] Autoplay: Disabling autoplay for pause
 Test Demo[736:14003] [MPAVController] Autoplay: Disabling autoplay
 Test Demo[736:14003] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 1, on player: 0)

和我的代码

NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"TestVideo" ofType:@"m4v"];
NSURL *streamURL = [NSURL fileURLWithPath:videoPath];

MPMoviePlayerController *player =
[[MPMoviePlayerController alloc] initWithContentURL: streamURL];
[player prepareToPlay];
[player.view setFrame: self.view.bounds];  // player's frame must match parent's
[self.view addSubview: player.view];
// ...
[player play];`

最佳答案

您的错误可能会导致很多问题。

1) 为您的 MPMoviePlayerController 设置属性并合成它。如果您的 MPMoviePlayerController 在播放之前释放,则可能会发生这种情况。

2)添加此代码player.movi​​ePlayer.movi​​eSourceType = MPMovieSourceTypeFile;

3) 按照documentation , .m4v 扩展名未提及播放。

4) 下面的屏幕截图将帮助您了解支持的格式。

enter image description here

关于objective-c - 在 ios 6 中播放视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13133023/

相关文章:

objective-c - 从 CGWindowListCopyWindowInfo 获取 NSWindow*

ios - NSLog在Xcode中无效

ios - 有焦点时突出显示 ios 文本框的简单方法?

ios - presentViewController :animated:completion: broken in iOS 6. x的ARC内存管理?

iphone - NSURL设置为nil而不是路径

ios - NSURLResponse - 如何获取状态码?

ios - 通过另一个类以编程方式将对象添加到 xib 文件

ios - pod 'MaterialComponents' 未添加所有 Material 组件

ios - 当我尝试释放我的类的对象时,ASIHTTP 请求不起作用并且应用程序崩溃

ios - 接触节点是 SpriteKit