views:

122

answers:

2

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

A: 

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.)
tc.
From what I've seen, the views aren't removed from the tab's view hierarchy when you switch between them. I was using MPMoviePlayer's view directly, then I tried using MPMoviePlayerViewController to see if that would help at all. It actually helped a bit, but the main problem was still there. I noticed when I switched tabs that I would have to double tap the video to get it to show up again. I believe that is what's happening without the view controller, but I don't see why. Any ideas?
Robbie
Actually, I just tried something. When switching between tabs, I had the MPMoviePlayerController enter and exit fullscreen mode. For whatever reason this works. There is a slight flash on the screen, but it only lasts for an instant, so I'm not worried about it.
Robbie
I'd be surprised if they weren't at least set to hidden; otherwise "background" tabs would eat up graphics performance unnecessarily. Entering and exiting fullscreen may restart the video decoding stream or something, which could fix it.
tc.
I tried messing with the hidden attribute, but it didn't help at all.
Robbie
A: 

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.

Robbie