11

What i have Done?

I am playing videos in an extended class of MPMoviePlayerViewController and have implemented orientation functions as follows

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {

    if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
        return FALSE;
    }
    else{
        return TRUE;
    }
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    [self setControlsPositions:toInterfaceOrientation];
}
-(BOOL)shouldAutorotate
{
    return YES;
}

What issue i am Facing?

The application works fine up till iOS6 on Both iPhone and iPad Almong with iPad (with iOS7) but the video does not rotate over iPhone with iOS7 installed.

What is the reason for such issue and how it can be resolved?

Update

I have found that the video does rotates if setMovieSourceType is set to MPMovieSourceTypeUnknown but does not rotate when set to `MPMovieSourceTypeStreaming

Quamber Ali
  • 2,170
  • 25
  • 46
  • Your conclusion clearly sounds like a bug in the MediaPlayer framework (yet another one). I highly recommend to file a bug report using your minimized example. – Till Nov 01 '13 at 20:54
  • @Till That seems a good option but where do i send the bug report. I mean send an email to apple or post in apple forum? – Quamber Ali Nov 03 '13 at 04:50
  • 1
    On the [apple website bug radar service](https://bugreport.apple.com). Addionally, it may be a good idea to file that one on [OpenRadar](http://openradar.appspot.com/) as well. – Till Nov 03 '13 at 17:42
  • +1 for the question clarity with proper headings – Syed Absar Nov 07 '13 at 07:35
  • @Till bug reported. They want me to send a sample now. – Quamber Ali Nov 13 '13 at 12:15
  • 1
    Please also file a report on OpenRadar and let us know which ID was used. This would be a great help to make sure the developer community receives some transparency on any progress (which otherwise is not available through Apple directly). – Till Nov 13 '13 at 17:02
  • try this: http://stackoverflow.com/questions/22491786/force-landscape-viewcontroller-in-ios-7/22491787#22491787 – Fede Cugliandolo Apr 01 '14 at 05:13

4 Answers4

2

After apple wanted me to give them a sample for the bug reported by me in iOS-7 i found that i wasn't pushing the view Controller rather i was adding the view to window. In such cases other view Controllers do get the orientation events but the MPMoviePlayerViewController subclass didn't so i just presentated the view controller instead of adding the its view and it worked.

Quamber Ali
  • 2,170
  • 25
  • 46
1

Try this solution:

At your AppDelegate.h:

@property  (nonatomic, assign) BOOL *fullScreenVideoIsPlaying;

At your AppDelegate.m:

@synthesize fullScreenVideoIsPlaying;

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
    NSUInteger orientations = UIInterfaceOrientationMaskPortrait;
    if (self.fullScreenVideoIsPlaying) {
        return UIInterfaceOrientationMaskAllButUpsideDown;
    }
    else {
        if(self.window.rootViewController){
            UIViewController *presentedViewController = [[(UINavigationController *)self.window.rootViewController viewControllers] lastObject];
            orientations = [presentedViewController supportedInterfaceOrientations];
        }
        return orientations;
    }}

At your ViewController:

in the viewDidLoad Method:

    myDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieStarted:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinished:) name:@"UIMoviePlayerControllerWillExitFullscreenNotification" object:nil];

And add those two methods in the same class:

-(void) movieStarted:(NSNotification*) notif {
     myDelegate.fullScreenVideoIsPlaying = YES;
}
-(void) youTubeFinished:(movieFinished*) notif {
     myDelegate.fullScreenVideoIsPlaying = NO;
}
Mutawe
  • 6,464
  • 3
  • 47
  • 90
0

The rotation methods changed with iOS 6 you will need to add the iOS 6 rotate methods to your view controller:

- (BOOL)shouldAutorotate {
    return YES:
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

And you need to add Supported interface orientations with the supported orientations to your apps info.plist.

From the iOS 6.0 release information:

The UIViewController class has new interfaces supporting the following behaviors:

  • New interfaces provide a clearer path for managing and tracking interface rotations.
rckoenes
  • 69,092
  • 8
  • 134
  • 166
  • 1
    Also that in info.plist all screen orientations are allowed except 'UIInterfaceOrientationPortraitUpsideDown' – Quamber Ali Sep 30 '13 at 12:49
  • Since iOS 6 if you do not implement the [`shouldAutorotate`](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926-CH3-SW124) the value is assumed to be `YES`. Then if the rotation is matching any of the supported rotation form the `info.plist` your view is just rotated. if you implement the above methods your `MPMoviePlayerViewController` sub class will rotate again. – rckoenes Sep 30 '13 at 13:06
  • that doesn't work i have updated the Question .. check it out – Quamber Ali Oct 23 '13 at 09:36
  • I dont think this answer would be plain wrong or badly researched or anything like that. It may not apply due to things not described in the question or maybe even due to bugs somewhere else. It certainly does not deserve being downvoted. – Till Nov 13 '13 at 17:10
0

i think device rotation is locked in the control centre cause it running fine in ipad ios 7.

jafar
  • 51
  • 1
  • 5