Problems with MPMoviePlayerController on iPad

I am trying to use a class MPMoviePlayerControlleron an iPad.

Here is my code:

multimediaPlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];               
multimediaPlayer.movieControlMode = MPMovieControlModeDefault;
[multimediaPlayer play];

and it works very well on the iPhone, but doesn’t want to run on the iPad. I hear the sound of the video, but the movie does not play. Why could this be this problem?

+3
source share
5 answers

Below code works perfect for my application. Hope he does the same for you. The main thing is to set the frame frame of mpMoviePlayerController. if you do not, it will hardly show the video.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    [[UIApplication sharedApplication] setStatusBarHidden:YES];

    // Register to receive a notification when the movie has finished playing. 
    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(moviePlayBackDidFinish:) 
                                                 name:MPMoviePlayerPlaybackDidFinishNotification 
                                               object:nil];

    // Register to receive a notification when the movie scaling mode has changed. 
    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(movieScalingModeDidChange:) 
                                                 name:MPMoviePlayerScalingModeDidChangeNotification 
                                               object:nil];
    kDomain = [NSString stringWithString:@"http://www.virtua-book.com/"];
    [navigationController setNavigationBarHidden:YES];

    NSURL *ur=[[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:@"IPAD" ofType:@"mp4"]];
    mpMCtr=[[MPMoviePlayerController alloc] initWithContentURL:ur];
    mpMCtr.fullscreen=YES;
    [mpMCtr setScalingMode:MPMovieScalingModeFill];
    [mpMCtr setShouldAutoplay:YES];
    [mpMCtr setControlStyle:MPMovieControlStyleNone];
    [mpMCtr setMovieSourceType:MPMovieSourceTypeFile];
    mpMCtr.view.frame = CGRectMake(0, 0, 1024, 768);
    [mpMCtr setRepeatMode:MPMovieRepeatModeNone];

    [mpMCtr play];

    [ur release];

    // Override point for customization after app launch    
    [navigationController.view addSubview:mpMCtr.view];
    [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];

    return YES;
}


//  Notification called when the movie finished playing.
- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
    [mpMCtr.view removeFromSuperview];
}
+4
source

Something like these lines, probably you want to do:

MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc] initWithContentUrl:movieUrl];
[self presentMoviePlayerViewController:mpvc];
+1
source

/ ( /), :

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];

...

- (void) moviePlayerPlaybackStateDidChange: (NSNotification *) notification {
 if (moviePlayer.playbackState == MPMoviePlaybackStateStopped) {
  [moviePlayer setContentURL:[moviePlayer contentURL]];
  [moviePlayer play];
 }
}
+1

, , , : .

multimediaPlayer.controlStyle = MPMovieControlStyleDefault;, - .

0
MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc]initWithContentURL:movieURL];
mp.moviePlayer.controlStyle = 2;
0
source

Source: https://habr.com/ru/post/1739157/


All Articles