如何使用 MPMoviePlayerViewController 在本地播放电影?

发布于 2024-09-30 05:50:07 字数 617 浏览 0 评论 0原文

我的资源文件夹中有一个名为 lebron.mp4 的 mp4 文件:

-(IBAction)videoButtonClicked:(id)sender{
    NSString *url = [[NSBundle mainBundle] 
                     pathForResource:@"lebron" 
                     ofType:@"mp4"];

    MPMoviePlayerViewController* moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:url]];

    moviePlayerViewController.view.backgroundColor = [UIColor blackColor];
    [self presentMoviePlayerViewControllerAnimated:moviePlayerViewController];

    [moviePlayerViewController release];    
}

显示电影播放器​​,但电影不播放。为什么?

I have an mp4 file called lebron.mp4 in my Resources folder:

-(IBAction)videoButtonClicked:(id)sender{
    NSString *url = [[NSBundle mainBundle] 
                     pathForResource:@"lebron" 
                     ofType:@"mp4"];

    MPMoviePlayerViewController* moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:url]];

    moviePlayerViewController.view.backgroundColor = [UIColor blackColor];
    [self presentMoviePlayerViewControllerAnimated:moviePlayerViewController];

    [moviePlayerViewController release];    
}

Displays the movie player, but the movie doesn't play. Why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

深海夜未眠 2024-10-07 05:50:07

您是否尝试像这样显示它:

[moviePlayerViewController play];
[window addSubview: MPMoviePlayerViewController.view];

did you try to display it like this :

[moviePlayerViewController play];
[window addSubview: MPMoviePlayerViewController.view];

?

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