MPMoviePlayerController breaks/stops after going to fullscreen in iOS6 MPMoviePlayerController breaks/stops after going to fullscreen in iOS6 ios ios

MPMoviePlayerController breaks/stops after going to fullscreen in iOS6


Are you stopping the video in viewWillDisappear: or viewDidDisappear:? Those methods get called when a video enters fullscreen on iOS 6, but not on any earlier iOS versions (a report has been filed at Open Radar for this "bug"). I posted this temporary solution on a similar question:

My temporary solution until the bug is fixed is to check the player's fullscreen Boolean value in viewWillDisappear: and/or viewDidDisappear:. If it returns YES, the movie is entering fullscreen mode and you should refrain from doing anything that might interrupt it.


I've solved this problem with a different approach. Since the main reason of the problem is iOS 6 calling viewWillDisappear: and/or viewDidDisappear: methods. I thought that maybe iOS also calling the same methods of MPMoviePlayerViewController. So I've created a Category for MPMoviePlayerViewController and implemented viewWillDisappear: and/or viewDidDisappear: methods. Interestingly it works. (by the way this is not recommended by apple)

Here are the codes;

Header (MPMoviePlayerViewController_FullscreenFix.h)

#import <MediaPlayer/MediaPlayer.h>@interface MPMoviePlayerViewController (MPMoviePlayerViewController_FullscreenFix)- (void)viewDidDisappear:(BOOL)animated;- (void)viewWillDisappear:(BOOL)animated;@end

Implementation (MPMoviePlayerViewController_FullscreenFix.m)

#import "MPMoviePlayerViewController_FullscreenFix.h"@implementation MPMoviePlayerViewController (MPMoviePlayerViewController_FullscreenFix)-(void)viewDidDisappear:(BOOL)animated{    [super viewDidDisappear:animated];}- (void)viewWillDisappear:(BOOL)animated{    [super viewWillDisappear:animated];}@end

Now my code is working on both iOS 6.1.3, 5.5.1 and 4.3.5 versions with the exactly same behavior.


I solved it by myself. As I add the Movie Player as a subview to a container view I don't need to use the actual view controller created with the MPMoviePlayerViewController which is intended to be used to present it modally or in some other vc hierarchy.

For the single purpose of having a Movie Player view that can be added to some other view as a subview the MPMoviePlayerController's view property is sufficient.

Until iOS 6 both worked but iOS 6 seems to differ in terms of ressource management/lifetime.

The example project is updated with working code.


matomo