iphone - MPMoviePlayerController 仅在 iOS 5 中显示黑屏

标签 iphone ios ios5 ios-simulator mpmovieplayercontroller

我正在下载一个 aac 文件并使用以下代码在 MPMoviePlayerController 中播放它

movieController = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:self.filePath]];
[self.view addSubview:movieController.view];
CGRect screenBound = [[UIScreen mainScreen] bounds];
CGSize screenSize = screenBound.size;
movieController.view.frame = CGRectMake(0,0,screenSize.width, screenSize.height);
[movieController setFullscreen:YES];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doneBtnMediaPlayer:) name:MPMoviePlayerWillExitFullscreenNotification object:nil];

movieController 是(非原子、强)类属性

这在除 iOS 5(和 iOS 5 模拟器)之外的所有 iOS 中都可以正常工作。 在 iOS 5 中,它显示黑屏并且文件在后台播放。

我注意到的另一件事是,当我在现有应用程序上运行应用程序时,它在 iOS5 上也可以正常工作。但是当我从设备中删除应用程序然后运行它时,它只显示黑屏。

最佳答案

看看这是否有帮助:

这是您的头文件 (.h) #进口 #导入

@interface ViewController : UIViewController

@property(nonatomic,retain)MPMoviePlayerViewController *playerController;

@end

这是您的实现文件 (.m) #导入“ViewController.h”

@interface ViewController ()

@end

@implementation ViewController
@synthesize playerController;

- (void)viewDidLoad
{
    [super viewDidLoad];
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"gold etche" ofType:@"mov"]];
playerController = [[MPMoviePlayerViewController alloc]initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:playerController];
[self.view insertSubview:playerController.view atIndex:0];
playerController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
playerController.moviePlayer.controlStyle = MPMovieControlStyleDefault;
playerController.moviePlayer.scalingMode = MPMovieScalingModeNone;

[playerController.moviePlayer play];

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];

}

@end

我在 IOS 5(5.0 和 5.1)和 IOS 6 中对此进行了测试,一切似乎都很好

关于iphone - MPMoviePlayerController 仅在 iOS 5 中显示黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13742448/

相关文章:

iphone - 流式传输 JPEG,检测 JPEG 的结尾

iPhone 表格单元格问题

ios - MvvmCross Xamarin.Forms(iOS): Using a TabbedPage within a MasterDetail page

ios - 在 nsarray of nsdictionaries 中搜索性能内存优化方式

ios - UIImageView 'unrecognized selector sent to instance' 难以捉摸的硬崩溃

ios - 后台应用程序/双击主页按钮时音频崩溃

iphone - iPhone在线多人游戏需要什么类型的网络编程?

iphone - 在 UITableView 页脚中放置一个按钮,并使 UITableViewCell 不在页脚下方

ios - Storyboard实例化 View Controller ,崩溃

iphone - 使用 Xcode 4.2 和 iOS 5 SDK 时是否可以针对旧版 iOS 版本?