0

MPMoviePlayerController work perfectly in ios4.3 devices.That same code not working ios5.0 devices.It show only black screen.This is the code.Thanks in advance..

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];
Anbu Raj
  • 831
  • 2
  • 8
  • 25
  • are you using ARC? how is the "`player_`" property declared in your .h file? where is the media file hosted (i.e. within the application or on a remote server)? – Michael Dautermann Apr 19 '12 at 06:33
  • not using ARC.Application having media file.@property (nonatomic, retain) MPMoviePlayerController *player_; – Anbu Raj Apr 19 '12 at 06:36
  • Just for fun, what happens when you comment out the "'[player release]; player = nil;`" line? Yes, I know it's a leak, but I want to know if things improve for you. B.T.W., a black screen usually means the MPMoviePlayerController exists, but the media file is bad or not found. – Michael Dautermann Apr 19 '12 at 06:39
  • Thanks for the reply..i didn't get any +ve result..Still not working.. – Anbu Raj Apr 19 '12 at 06:48
  • @anbu raj Is your player_ initialised ? – iDroid Apr 19 '12 at 07:46
  • Here is one solution. This works for me.. http://stackoverflow.com/questions/4101380/avurlasset-refuses-to-load-video – Anbu Raj May 04 '12 at 06:16

1 Answers1

0

Try this this will work in ios 5 Yesterday only I try It work nicely.

 -(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];
 }
vishiphone
  • 750
  • 7
  • 14