Search code examples
iphoneuiviewmpmovieplayercontroller

Playing video in custom size screen - view in iPhone


Suppose user taps on a button and video begins to play. Now when video plays, it always in full screen mode.

Video should be played in a portrait mode (but normally video is played in landscape mode). How can I do this?


Solution

  • @interface MPMoviePlayerController (extend) 
     -(void)setOrientation:(int)orientation animated:(BOOL)value; 
    @end 
    
    moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieUR]; 
    [moviePlayer setOrientation:UIDeviceOrientationPortrait animated:NO]; 
    if (moviePlayer) 
    { 
        [self.moviePlayer play]; 
    } 
    

    This Solution will be rejected by Apple, as setOrientation for movie player is the Private API. You need to be careful, but it may work on Jailbroke iPhones.