MPMoviePlayerController size

How can I resize MPMoviePlayerController? I don't want it to play full screen, I just want the part of the view where the video is playing. I searched a lot but couldn't find a good answer.

thank

0


source to share


2 answers


Try this sample, Import #import <MediaPlayer/MediaPlayer.h>

in your header file and include the MediaPlayer environment 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];
}

      

+1


source


Try to run the player at your size and then disable the 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 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 reproduction 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];   
}

      

0


source







All Articles