How to view a video in Landscape

Discussion in 'iOS Programming' started by B-ram, Nov 3, 2010.

  1. B-ram macrumors newbie

    Joined:
    Nov 3, 2010
    Location:
    Zaandam, Zaanstad, Nederland
    #1
    Hi guys,

    I have a video in my application but its portrait.

    I want it Landscape but i really don't have any idea how to do that.

    i used this code to make my video:

    Code:
    - (IBAction)playMovie:(id)sender
    {
     NSString *filepath = [[NSBundle mainBundle] pathForResource:@"BAZO" ofType:@"m4v"];
     NSURL *fileURL = [NSURL fileURLWithPath:filepath];
     MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
    
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackComplete:)name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];
    
     [self.view addSubview:moviePlayerController.view];
     moviePlayerController.fullscreen = YES;
     //Uncomment om beeld formaat aan te passen
     //moviePlayerController.scalingMode = MPMovieScalingModeAspectFill;
     [moviePlayerController play];
    }
    
    - (IBAction)playSecondMovie:(id)sender{
    
     NSString *filepath = [[NSBundle mainBundle] pathForResource:@"00 01. Welcome" ofType:@"mov"];
     NSURL *fileURL = [NSURL fileURLWithPath:filepath];
     MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
    
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackComplete:)name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];
    
     [self.view addSubview:moviePlayerController.view];
     moviePlayerController.fullscreen = YES;
     //Uncomment om beeld formaat aan te passen
     //moviePlayerController.scalingMode = MPMovieScalingModeAspectFill;
     [moviePlayerController play];
    
    }
    
    - (void)moviePlaybackComplete:(NSNotification *)notification
    {
     MPMoviePlayerController *moviePlayerController = [notification object];
     [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];
    
     [moviePlayerController.view removeFromSuperview];
     [moviePlayerController release];
    }
    
    -(void) tableView: (UITableView*) tableView 
    didSelectRowAtIndexPath: (NSIndexPath*) indexPath
    {
    
    
     NSString *filepath = [[NSBundle mainBundle] pathForResource:@"BAZO" ofType:@"m4v"];
     NSURL *fileURL = [NSURL fileURLWithPath:filepath];
     MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
    
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackComplete:)name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];
    
     [self.view addSubview:moviePlayerController.view];
     moviePlayerController.fullscreen = YES;
     //Uncomment om beeld formaat aan te passen
     //moviePlayerController.scalingMode = MPMovieScalingModeAspectFill;
     [moviePlayerController play];
    
     /*-(void)loadVideo:(NSString *)name ofType:(NSString *)type{
      NSURL *url=[NSURL fileURLWithPath:[mainBundle pathForResource:@"BAZO"  ofType:@"m4V"]]
      if (!mp) mp = [[MPMoviePlayerController alloc] initWithContentURL:url];
      [mp play];
     }*/
    }
    
    I used this code, to make it landscape:

    Code:
    [MPMoviePlayerController setOrientation:UIDeviceOrientationLandscapeLeft animated:NO];
    
    but it gives me the warning : 'MPMoviePlayerController' may not respond to '-setOrientation:animated:'

    Whats happening? Is it a wrong method? please help me out of this.

    Thanks!

    Bram
     
  2. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
    #2
    Why do you think MPMoviePlayerController should respond to that method?

    One way to force landscape is apply a rotation (CGAffineTransformMakeRotation) to self.view.
     
  3. B-ram thread starter macrumors newbie

    Joined:
    Nov 3, 2010
    Location:
    Zaandam, Zaanstad, Nederland
    #3
    I don't know somebody told me that.

    ok thanks for the tip. But all the tools like play and the done button. Doe they turn to?

    tx
     

Share This Page