iPhone OS 3.0 无法播放电影

发布于 2024-09-16 01:59:36 字数 797 浏览 2 评论 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

往事随风而去 2024-09-23 01:59:36

啊,是自动释放部分造成了破坏。

        MPMoviePlayerController *moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:selectedLink]] autorelease];
    [moviePlayer play];

        MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:selectedLink]];
    [moviePlayer play];

干杯

Ahh its the autorelease part which is doing the wreckage.

From

        MPMoviePlayerController *moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:selectedLink]] autorelease];
    [moviePlayer play];

to

        MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:selectedLink]];
    [moviePlayer play];

Cheers

白况 2024-09-23 01:59:36

我想您应该将 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文