0

MPMoviePlayerController は ios4.3 デバイスで完全に動作します。同じコードは ios5.0 デバイスでは動作しません。黒い画面しか表示されません。これがコードです。よろしくお願いします。

MPMoviePlayerController *player=[[MPMoviePlayerController alloc] initWithContentURL: mediaUrl ];

player.controlStyle = MPMovieControlStyleFullscreen;

[player.view setFrame: self.view.bounds];  

self.player_=player;

[player release],player = nil;

[self.view addSubview:player_.view];

[player_ prepareToPlay];

[player_ play];
4

1 に答える 1

0

これを試してみてくださいこれはios 5で動作します 昨日だけ試してみました うまく動作します。

 -(IBAction)playVideo:(id)sender
{
   NSURL *url = [NSURL URLWithString:@"http://www.ebookfrenzy.com/ios_book/movie/movie.mov"];

   MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
  // NSURL *url=[NSURL URLWithString:@""];
  // MPMoviePlayerController *moviePlayer=[[MPMoviePlayerController alloc]initWithContentURL:url];
  [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
  moviePlayer.controlStyle=MPMovieControlStyleDefault;
  moviePlayer.shouldAutoplay=YES;
  [self.view addSubview:moviePlayer.view];
  [moviePlayer setFullscreen:YES animated:YES];

}
-(void)moviePlayBackDidFinish:(NSNotification *)notification
 {
  MPMoviePlayerController *moviePlayer=[notification object];
  [[NSNotificationCenter defaultCenter]removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
  if([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)])
    {
        [moviePlayer.view removeFromSuperview];
    }
  [moviePlayer release];
 }
于 2012-05-07T10:22:12.787 に答える