0

How can I change the size of a MPMoviePlayerController? I don't want to let it play in fullscreen, I just want a part of the view where the video is playing. I've searched a lot, but I couldn't find a good answer.

Thanks

2 Answers2

1

Try this sample, Import #import <MediaPlayer/MediaPlayer.h> in your header file and include MediaPlayer framework in your project .

    - (IBAction)testVideoAction:(id)sender {
    NSURL *movieURL = [NSURL URLWithString:@"http://www.tools4movies.com/dvd_catalyst_profile_samples/Harold%20Kumar%203%20Christmas%20bionic.mp4"];
    MPMoviePlayerViewController *movieController = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
        movieController.view.frame = CGRectMake(10, 10, 300, 300);
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
    [view addSubview:movieController.view];    
    [self.view addSubview:view];       
    [movieController.moviePlayer play];
}
karthik
  • 1,271
  • 1
  • 14
  • 27
0

Try to init player with your size and then disable controls:

-(void) configurePlayer {

self.moviePlayer = [[MPMoviePlayerController alloc] init];

[self.moviePlayer setControlStyle:MPMovieControlStyleNone];

self.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;

[self.moviePlayer setMovieSourceType:(MPMovieSourceTypeStreaming)];

CGRect frame = CGRectMake(yourX, yourY, yourWidth, yourHeight);

[self.moviePlayer.view setFrame:frame];  // player's frame must match parent's

[self.view addSubview: self.moviePlayer.view];

[self.view bringSubviewToFront:self.moviePlayer.view];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:self.moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(metadataUpdate:)
                                             name:MPMoviePlayerPlaybackStateDidChangeNotification
                                           object:nil]; 
 }

For playing use this method

-(void) playStream {
NSURL *url = [NSURL URLWithString:@"http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8"];
[self.moviePlayer setContentURL:url];
[self.moviePlayer prepareToPlay];
[self.moviePlayer play];   
}
protikhonoff
  • 565
  • 4
  • 6