一个视图中有多个 MPMoviePlayer?

发布于 2024-12-27 20:00:10 字数 1372 浏览 1 评论 0原文

我需要在一个视图中显示多个电影播放器​​。

我知道我只能播放一个视频。

我的问题是,我添加到视图中的两个 MPMovieplayer 中只有一个显示了控制按钮。

我可以做什么来解决我的问题?

我使用此代码添加电影播放器​​:

MPMoviePlayerController * moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];


    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(playerPlaybackDidFinish:) 
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:moviePlayer];

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(playerDidEnterFullscreen:) 
                                                 name:MPMoviePlayerDidEnterFullscreenNotification
                                               object:moviePlayer];

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(playerDidExitFullscreen:)
                                                 name:MPMoviePlayerDidExitFullscreenNotification
                                                object:moviePlayer];

    moviePlayer.view.frame = rect;

    [movie setContentURL:contentURL];
    [movie prepareToPlay];

    [self addSubview:moviePlayer.view];

I need to display more than one movieplayer in a view.

I know I can only play one video.

My problem is that only one of the two MPMovieplayer, I have added to the view, shows me the control buttons.

What can I do to solve my problem?

I use this code to add a movieplayer:

MPMoviePlayerController * moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];


    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(playerPlaybackDidFinish:) 
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:moviePlayer];

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(playerDidEnterFullscreen:) 
                                                 name:MPMoviePlayerDidEnterFullscreenNotification
                                               object:moviePlayer];

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(playerDidExitFullscreen:)
                                                 name:MPMoviePlayerDidExitFullscreenNotification
                                                object:moviePlayer];

    moviePlayer.view.frame = rect;

    [movie setContentURL:contentURL];
    [movie prepareToPlay];

    [self addSubview:moviePlayer.view];

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

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

发布评论

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

评论(2

人疚 2025-01-03 20:00:10

我认为这是不可能的。请看这个问题的答案
在 iPAD 上播放多个视频

您必须使用 AVPlayer多个视频观看,查看此
这是另一个 AVPlayer 教程
您还可以从苹果开发者门户网站 链接

这个

href="https://stackoverflow.com/questions/6258573/playing-many- Different-videos-on-iphone-using-avplayer">问题还提到了有关向 AVPlayer BR、Hari

I think its not possible. Please see the answer for this question
Playing Multiple Videos on iPAD

You will have to use AVPlayer for multiple video viewing, see this
Here is another tutorial for AVPlayer
You can also check this from apple developer portal, link

This question also says something about adding controls to AVPlayer

BR, Hari

九歌凝 2025-01-03 20:00:10

您好,在 ios 中无法播放超过 1 个视频,因为一次只能播放一个线程。

我在 iPad 应用程序中遇到了同样的问题,但我找到了替代解决方案。

我想在 1 个视图控制器中播放更多视频,但这些视频只有 4 到 5 秒。

我制作该视频的多个连续图像帧并制作 .gif 文件并将其显示在 UIWebView 中。效果很好。

Hi this is not possible to play more than 1 video in ios because only one thread at a time .

I face same issue in my iPad application but I've found an alternate solution.

I want to play more video in 1 view controller , but these videos are 4 to 5 sec's only.

I make number of continuous image frames of that video's and make .gif files and show this in a UIWebView. it works fine.

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