iphoneobjective-cios4ios5mpmovieplayercontroller

iPhone app:MpMoviePlayer not playing movie in iPad with ios5


I have created my iPhone app in Xcode 4 with base SDK 4.3

In my iPhone app I have used MPMovieplayercontroller and using that I am playing Video

It is playing my video file in my iPod Touch with IOS 4.3 but if I install same project in my iPad with iOS 5, it is showing black screen only but not playing video.

what could be wrong?

Here is the code in .h file

 MPMoviePlayerController *moviePlayer;

in .m file

 -(void)playVideo{
 NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"testbild1" ofType:@"m4v"]];
 moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
UIView *testview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
[testview addSubview:moviePlayer.view];
 [self.view addSubview:testview];
  }  

   - (void)moviePlaybackComplete:(NSNotification *)notification  
   {  
    MPMoviePlayerController *moviePlayerController = [notification object];  
    [[NSNotificationCenter defaultCenter] removeObserver:self  
                                               name:MPMoviePlayerPlaybackDidFinishNotification  
                                               object:moviePlayerController];  

 [moviePlayerController.view removeFromSuperview];  


 }

Solution

  • It doesn't look like you're setting autoplay

    shouldAutoplay
    A Boolean that indicates whether a movie should begin playback automatically.
    
    @property (nonatomic) BOOL shouldAutoplay
    

    So like:

    moviePlayer.shouldAutoplay = true;
    

    You should also be probably calling prepareToPlay and play from the MPMediaPlayback protocol that MPMoviePlayerController implements

    Old Post (should have been a comment):

    What version iOS? iOs 5.1 beta just came out and alters how MPMoviePlayerController works.

    You can get details on Apple's iOS beta site but I can't print them here YAY EULA.


    EDIT

    Now that the OS is public, here's the relevant documentation (registration -- you might have to pay the $100 as well, I forget...)