iPhone OS 3.0 无法播放电影
以下代码曾经可以工作,但现在不行,而且我没有对其进行任何更改。
if ([self respondsToSelector:@selector(presentMoviePlayerViewControllerAnimated:)]) {
MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:selectedLink]];
[self presentMoviePlayerViewControllerAnimated:moviePlayer];
[moviePlayer release];
}
else {
MPMoviePlayerController *moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:selectedLink]] autorelease];
[moviePlayer play];
}
因此,如果操作系统支持 PresentMoviePlayerViewControllerAnimated 方法,我们将使用此方法,但如果其操作系统 < 3.2 我们使用旧方法,但这在我的 iPhone 第一代 OS 3.0.1 或 iPod Touch 第二代 OS 3.1.3 上不再有效。当代码被触发时什么也不会发生。
希望你能帮助我。
干杯
The following code used to work but now it doesn't and I have not changed anything about it.
if ([self respondsToSelector:@selector(presentMoviePlayerViewControllerAnimated:)]) {
MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:selectedLink]];
[self presentMoviePlayerViewControllerAnimated:moviePlayer];
[moviePlayer release];
}
else {
MPMoviePlayerController *moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:selectedLink]] autorelease];
[moviePlayer play];
}
So if the OS supports the method presentMoviePlayerViewControllerAnimated we use this approach but if its OS < 3.2 we use the old method but this doesn't work anymore on my iPhone 1st gen OS 3.0.1 or iPod Touch 2nd gen OS 3.1.3. Nothing happens when the code is fired.
Hope you can help me.
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
啊,是自动释放部分造成了破坏。
从
到
干杯
Ahh its the autorelease part which is doing the wreckage.
From
to
Cheers
我想您应该将 MPMoviePlayerController 视图框架设置为要显示它的 CGRect,然后在播放之前将此视图添加为子视图。查看Apple 文档
I guess you shall set the MPMoviePlayerController view frame to the CGRect you want to display it and then add this view as a subview before playing. Have a look at Apple Documentation