UITabBarController 内的 MPMoviePlayerController

发布于 2024-09-15 07:35:31 字数 347 浏览 3 评论 0原文

好的,事情就是这样。我有一个包含 UITabBarController 的 UIViewController。该选项卡栏为每个选项卡按钮都有一个 UIViewController。现在,其中一个选项卡按钮内部是一个 MPMoviePlayerController,它正在通过网络播放流。播放流效果很好,您可以看到视频并听到音频。

问题是当您导航到另一个选项卡时。音频仍在播放,这很好,但当您返回流时,视频是黑色的。音频仍在播放,但视频也需要播放。

以前有人遇到过这个问题吗?

我目前正在使用 iOS 4.0 和 iPhone 3GS 进行构建。

如果需要更多信息,请询问,我会尽力回答。

谢谢, 罗比

Ok, so here's the thing. I have a UIViewController that contains a UITabBarController. That tab bar has a UIViewController for each tab button. Now, inside one of the tab buttons is an MPMoviePlayerController that is playing a stream from over the network. Playing the stream works just fine and you can see the video and hear the audio.

The problem is when you navigate to another tab. The audio still plays, which is good, but when you go back to the stream, the video is black. The audio is still playing, but the video needs to be playing too.

Has anyone run into this problem before?

I'm currently using iOS 4.0 to build against and an iPhone 3GS.

If more information is needed, just ask and I'll do my best to answer.

Thanks,
Robbie

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

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

发布评论

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

评论(3

Hello爱情风 2024-09-22 07:35:31

如果视图不在屏幕上,可能会发生奇怪的事情(我相信当您切换选项卡时它会从视图层次结构中删除)。

  • 您是否尝试过直接使用 MPMoviePlayer 的视图? (不是 MPMoviePlayerController)
  • 您可以添加和删除视图并保持电影播放吗?
  • 暂停和恢复有帮助吗?
  • 您可以在视图控制器之间传递视图,或者使其成为 viewWillDisappear 中窗口的直接子视图并将其移回到 viewDidAppear 中吗? (我不确定视图是否已从 viewWillAppear/viewDidDisappear 的层次结构中删除。)

Strange things might happen if the view isn't on-screen (I believe it's removed from the view hierarchy when you switch tabs).

  • Have you tried using MPMoviePlayer's view directly? (not MPMoviePlayerController)
  • Can you add and remove the view and keep the movie playing?
  • Does pausing and resuming help?
  • Could you pass the view around between view controllers, or maybe make it a direct subview of the window in viewWillDisappear and move it back in viewDidAppear? (I'm not sure if the view's been removed from the hierarchy in viewWillAppear/viewDidDisappear.)
阳光下慵懒的猫 2024-09-22 07:35:31

我继续采用的解决方案是非常快速地进入全屏模式并退出全屏模式。这可能不是最好的事情,但它正在发挥作用。

The solution I'm going ahead with is entering fullscreen mode and exiting fullscreen mode very quickly. It may not be the best thing, but it's working.

狼性发作 2024-09-22 07:35:31

这种情况在 iOS 6 上仍然会发生。如果我有两个电影播放器​​(每个选项卡上一个),即使它们没有播放,如果我从第一个选项卡切换到秒选项卡并返回到第一个选项卡,电影播放器​​将会变黑。

我的解决方案就像在 -viewDidAppear: 上调用 prepareToPlay 一样简单:

- (void)viewDidAppear:(BOOL)animated;
{
    [super viewDidAppear:animated];
    [self.moviePlayer prepareToPlay];
}

我相信这会将 MPMoviePlayerController 的共享内部视图添加到视图层次结构中。

This still happens on iOS 6. If I have two movie player (one on each tab), even if they are not playing, if I switch form the first to the seconds tab and return to the first, the movie player will be black.

My solution was as simple as calling prepareToPlay on -viewDidAppear::

- (void)viewDidAppear:(BOOL)animated;
{
    [super viewDidAppear:animated];
    [self.moviePlayer prepareToPlay];
}

I believe this will add the shared internal view of MPMoviePlayerController to the view hierarchy.

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