Joris Weimar
Joris Weimar

Reputation: 4921

MPMoviePlayerController quirck? Can't tap its view when playing the video again after user exits with "Done"

A class A loads the movie using an MPMoviePlayerController. I call prepareToPlay and wait with displaying the movie until I get loadState = 3. If I play the video and let it go to the end and then play it again, everything works fine. However, if I end the video with "Done", thus getting in the MPMovieFinishReasonUserExited reason for exiting, and I replay the video again, I can tap the controls but not the video screen. When the controls disappear there's no way to get the controls back again because the view doesn't respond. This only happens in iOS 5.1 but not iOS 4.3 (both simulator and actual device). Any ideas?

EDIT:

I figured one thing out. I did some debugging on the subviews of the MPMoviePlayerController's view and I found out that the first time it plays we have:

<MPSwipableView: 0x9b671f0; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x9b67290>>

whereas after playing it the second time, we have:

<MPSwipableView: 0x9b671f0; frame = (0 0; 320 480); hidden = YES; autoresize = W+H; layer = <CALayer: 0x9b67290>>

Why does it hide the view that register touches?? Is this a bug?

EDIT 2:

Unfortunately, the above observation seems to be unrelated. I manually set the hidden to NO, and I still can't get it to respond to taps. When I reload the movie, it's no problem.

Upvotes: 0

Views: 502

Answers (2)

Mike Z
Mike Z

Reputation: 56

I ran into the same problem and came across this post. I found that unless the URL of the file changes before you replay the video, the controls will not reappear on tap. To get around this issue, I simply release the previous MPMoviePlayerController and alloc and init a new one.

Changing the MPMoviePlayerController's file URL to something else, then back to the video might work too, but I haven't tested that.

Upvotes: 1

Till
Till

Reputation: 27587

I have seen this issue once the app does superfluous controlStyle changes. Check your setup/teardown event handlers. Make sure you only set controlStyle's that are not active already.

if (player.controlStyle != newControlStyle)
{
    player.controlStyle = newControlStyle;
}

This appears to make no sense but rest assured, it does trigger MPMoviePlayerController bugs if not done this way.

Upvotes: 0

Related Questions