MPMoviePlayerController 仅在通用应用程序中抛出错误
我的应用程序启动时以全屏模式播放视频。从 3.0 到 4.1 一切都运行完美。
但是,如果我为通用应用程序编译相同的代码,它将在 iPad 上运行,但不再在 iPhone(模拟器)上运行。
有人解决这个问题了吗?
这是代码:
if ([self respondsToSelector:@selector(presentMoviePlayerViewControllerAnimated:)]) {
videoPath = [[NSBundle mainBundle] pathForResource:@"portrait" ofType:@"mov"];
videoURL = [NSURL fileURLWithPath:videoPath];
MPMoviePlayerController *aMoviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
self.moviePlayerController = aMoviePlayerController;
[aMoviePlayerController release];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startVideo:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
[moviePlayerController.view setFrame:self.view.bounds];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.controlStyle = MPMovieControlStyleNone;
} else {
//OS < 3.2
videoPath = [[NSBundle mainBundle] pathForResource:@"landscape" ofType:@"mov"];
videoURL = [NSURL fileURLWithPath:videoPath];
MPMoviePlayerController *aMoviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
self.moviePlayerController = aMoviePlayerController;
[aMoviePlayerController release];
moviePlayerController.movieControlMode = MPMovieControlModeHidden;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startVideo:) name:MPMoviePlayerContentPreloadDidFinishNotification object:nil];
}
这是错误:
-[MPMoviePlayerControllerOld 视图]:发送到实例的选择器无法识别
0x7924470
即使我尝试像这样阻止这种情况...
if ([moviePlayerController respondsToSelector:@selector(view)]) {
[moviePlayerController.view setFrame:self.view.bounds];
}
...仍然会抛出错误。
My app plays a video in fullscreen mode when the app is started. Everything is working flawlessly from 3.0 to 4.1.
However, if I compile the same code for a universal app, it will work on the iPad, but will not work on the iPhone (simulator) anymore.
Has anyone solved this problem?
Here's the code:
if ([self respondsToSelector:@selector(presentMoviePlayerViewControllerAnimated:)]) {
videoPath = [[NSBundle mainBundle] pathForResource:@"portrait" ofType:@"mov"];
videoURL = [NSURL fileURLWithPath:videoPath];
MPMoviePlayerController *aMoviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
self.moviePlayerController = aMoviePlayerController;
[aMoviePlayerController release];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startVideo:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
[moviePlayerController.view setFrame:self.view.bounds];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.controlStyle = MPMovieControlStyleNone;
} else {
//OS < 3.2
videoPath = [[NSBundle mainBundle] pathForResource:@"landscape" ofType:@"mov"];
videoURL = [NSURL fileURLWithPath:videoPath];
MPMoviePlayerController *aMoviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
self.moviePlayerController = aMoviePlayerController;
[aMoviePlayerController release];
moviePlayerController.movieControlMode = MPMovieControlModeHidden;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startVideo:) name:MPMoviePlayerContentPreloadDidFinishNotification object:nil];
}
And here's the error:
-[MPMoviePlayerControllerOld view]: unrecognized selector sent to instance
0x7924470
Even if I try to prevent this like so...
if ([moviePlayerController respondsToSelector:@selector(view)]) {
[moviePlayerController.view setFrame:self.view.bounds];
}
...the error is still thrown.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
几天前我遇到了同样的错误。只需要将基础 sdk 从 3.2 更改为 4.1
希望有帮助
I got the same error few days ago. It needed only change the base sdk from 3.2 to 4.1
Hope it helps
我还没有对该错误的解释。但这似乎有效(需要在较旧的设备上进行测试):
如果我能记得为什么我首先以其他方式这样做就好了;)
I have no explanation for the error, yet. But this seems to work (need to test on older devices):
If only I could remember why I did it the other way in the first place ;)