ios5 - 初始化并播放 MPMoviePlayerController 返回黑屏

标签 ios5 mpmovieplayercontroller xcode4.3

我正在尝试使用 Xcode 中的一些示例代码在 iPhone Simulator 5.1 下播放 mp4 视频。我创建了 MPMovieViewController 和 MPMovieController,提供包含 mp4 的本地路径并将其作为 subview 添加到我的根 Controller 。

当我在 iPhone Simulator 下运行它时,只显示后屏。我已经在 SO 中尝试了一些针对相同问题的建议,但仍然不起作用。

这是代码:

    NSURL *myURL = [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:@"VIDEO_CX75_01" ofType:@"mp4"]];

    MPMoviePlayerViewController *moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:myURL];        
    MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL: myURL];

    [self presentMoviePlayerViewControllerAnimated:moviePlayerViewController];

    [player.view setFrame: self.view.bounds];  // player's frame must match parent's
    [self.view addSubview: player.view];
    player.view.frame = self.view.frame;

    player.initialPlaybackTime = -1.0;
    [player prepareToPlay];
    [player play];

我在哪里做错了?

PS:我在 Xcode 4.3.2

最佳答案

我遇到了同样的问题,我所做的就是让玩家成为一个强大的属性并合成它。有效。

也应该适用于您的情况。!

关于ios5 - 初始化并播放 MPMoviePlayerController 返回黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10326980/

相关文章:

ios - 如何将 UITableViewCell 拖放到另一个 UITableView 上?

javascript - Html 通过 jquery/javascript 在 iphone 上保持键盘可见

ios - MPMoviePlayerController 循环问题

objective-c - clang : error: cannot specify both '-fobjc-arc' and '-fobjc-gc'

objective-c - 如何在 Cocoa/Objective-C 中将文件编码和解码为 Base64

objective-c - libtool 在 XCode 4.3 上失败,退出代码为 1

list - TableView 的索引列表显示点 iOS 5+

iphone - CGAffineTransform MakeRotation 缩放图像

ios - 播放前将视频置于暂停状态

objective-c - 从 NStimeInterval 准确转换为 CMTime