Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7622789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:32:29+00:00 2026-05-31T04:32:29+00:00

I want to rotate my movie player view explicitly (not using Autorotation delegate) .

  • 0

I want to rotate my movie player view explicitly (not using Autorotation delegate). I wrote following code for that and also put comments in it. The parent view of movie player does rotate but not movie player view itself. Could someone please assist me here what I am doing wrong? Thanks.

#import "CustomMoviePlayer.h"
#define degreesToRadian(x) (M_PI * (x) / 180.0)
#define radianToDegrees(x) ((x) * 180.0/M_PI)

@implementation CustomMoviePlayer

@synthesize moviePlayer, myParentViewController;

-(void)playMovie:(NSString*)filePath onViewController:(UIViewController*)controller
{

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rotateMoviePlayer) name: UIDeviceOrientationDidChangeNotification object:nil];
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];   

    myParentViewController = controller;

    NSURL *url = [NSURL fileURLWithPath:filePath];

    moviePlayer =  [[MPMoviePlayerController alloc] initWithContentURL:url];
    moviePlayer.controlStyle = MPMovieControlStyleDefault;
    moviePlayer.shouldAutoplay = YES;

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackComplete:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackStateChanged:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:moviePlayer];

    [controller.view addSubview:moviePlayer.view];
    [moviePlayer setFullscreen:YES animated:YES];
}

- (void)moviePlaybackStateChanged:(NSNotification *)notification
{
    NSLog(@"State changed... %d", [moviePlayer playbackState]);
}

- (void)moviePlaybackComplete:(NSNotification *)notification
{
    NSLog(@"Finished video...");

    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackStateDidChangeNotification object:moviePlayer];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];

    [myParentViewController.view setTransform:CGAffineTransformIdentity];
    [moviePlayer.view removeFromSuperview];
    [moviePlayer release];
}

-(void)rotateMoviePlayer
{
    NSLog(@"Rotate movie player");

    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];

    if (orientation != UIDeviceOrientationUnknown) {

        CGAffineTransform transform = CGAffineTransformMakeRotation(degreesToRadian(0));

        switch (orientation) {
            case UIDeviceOrientationLandscapeLeft:
                transform = CGAffineTransformMakeRotation(M_PI / 2); 
                break;
            case UIDeviceOrientationLandscapeRight:
                transform = CGAffineTransformMakeRotation(-M_PI / 2);
                break;
            case UIDeviceOrientationPortraitUpsideDown:
                transform = CGAffineTransformMakeRotation(M_PI);
                break;  
            default:
                break;
        }
        // This view does rotate and I can see it rotating when there is no moviePlayer on top of it!
        [myParentViewController.view setTransform:CGAffineTransformIdentity];
        [myParentViewController.view setTransform:transform];

        // It doesn't mater whether I put following two lines or not...Movie player view doesn't rotate!
        [moviePlayer.view setTransform:CGAffineTransformIdentity];
        [moviePlayer.view setTransform:transform];
    }    
}

- (void)dealloc {
    [moviePlayer release];
    [super dealloc];
}

@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:32:30+00:00Added an answer on May 31, 2026 at 4:32 am

    You are using MPMoviePlayerController in fullscreen mode, hence the rotation/s applied to its view (and/or its superview) are not being effective.

    When using fullscreen mode, MPMoviePlayerController is actually using a different approach by adding its rendering layer directly to a UIWindow – that is, it does effectively not use its view property.

    For getting the current UIWindow when a movie is playing in fullscreen, you may use the following snippet;

    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    if (!window)
    {
        window = [[UIApplication sharedApplication].windows objectAtIndex:0];
    }
    

    Once you got that window, apply your rotation/s directly to it.

    This however will result in many possible issues that are hard to overcome (trust me, been there, got a collection of Tshirts). As an alternative way, I would strongly suggest you to use a fake-fullscreen mode.

    Instead of initializing the player like you did

    [moviePlayer setFullscreen:YES animated:YES];
    

    Why not simply initializing its view’s frame size to the entire screen – or the bounds of its superview like this

    moviePlayer.view.frame = myParentViewController.view.bounds;
    

    Then, for getting the fullscreen interface, use the following control style:

    moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
    

    That way, your resulting playback will adhere to any transformation done on the superview and you will be free of side effects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is that I want to rotate the UIImageView of a UIButton .
I find this pretty confusing. When you want to rotate a view, it's going
I have a Cube which I want to rotate using mouse motion. So if
I want to rotate a single word of text by 90 degrees, with cross-browser
I want to rotate the location where temporary files are written however it is
I have an UIImageView which I want to rotate a little bit, but I
I want to display and rotate a single 3D model, preferably textured, on the
I want to have in my GUI capability for scale, rotate and crop images
So I have that panel or any other mxml component. I want somehow to
I have a UIImageView object that I rotate with frame property and CFAffineTransformMakeRotate and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.