8

MPMoviePlayer is not playing video. I'm running iOS 7 and getting the same error on the device and simulator:

2013-10-02 12:49:18.246 xxxx[688:60b] _itemFailedToPlayToEnd: {
kind = 1;
new = 2;
old = 0;

}

I've tried playing a video from the internet and file system, but no luck. My code is very straightforward:

    self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://stream.qtv.apple.com/events/mar/123pibhargjknawdconwecown/12oihbqeorvfhbpiubqnfv3_650_ref.mov"]];
    self.moviePlayer.view.frame = self.view.bounds;
    self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
    [self.view addSubview:self.moviePlayer.view];
    [self.moviePlayer prepareToPlay];

The URL listed is a valid movie: http://stream.qtv.apple.com/events/mar/123pibhargjknawdconwecown/12oihbqeorvfhbpiubqnfv3_650_ref.mov

I've also tried using MPMoviePlayerViewController, but that didn't work either.

backofthecup
  • 1,091
  • 2
  • 6
  • 7
  • see http://stackoverflow.com/questions/22068681/itemfailedtoplaytoend-error-when-playing-video-in-mpmovieplayercontroller – Hasan Sawaed May 06 '14 at 13:42

3 Answers3

3

MPMovieSourceTypeStreaming seems to be buggy on iOS 7. On my app, I'm streaming a video from the web (same as you), and the problem disappear with this source type :

self.moviePlayer.movieSourceType = MPMovieSourceTypeFile;

I know it's strange because we're streaming the video, but this is the only solution that works for me.

Hope it helps :)

Rémy Virin
  • 3,379
  • 23
  • 42
1

1.change the mov file to mp4 file,it seems that the player can't support the mov file

2.delete the code self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;

or change to self.moviePlayer.movieSourceType = MPMovieSourceTypeFile;

3.add code [self.moviePlayer setFullscreen:YES]; after [self.view addSubview:self.moviePlayer.view];

note:You must note the sequence,otherwise you can only hear the sound but can't watch the movie

If you want to use MPMoviePlayerViewController,like this:

 MPMoviePlayerViewController *moviePlayerViewController;
   moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://.../movie.mp4"]];//note:mp4 file
    [self presentMoviePlayerViewControllerAnimated:moviePlayerViewController];

Important:If the URL is error,you will also get the same error. eg:this is wrong

moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"movie.mp4"]];

to correct it:

If the URL is a web URL,then like this:

moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://..../movie.mp4"]];

else if the file is a local file,then like this:

moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"movie" ofType:@"mp4”]]];
慭慭流觞
  • 436
  • 5
  • 3
0

Try this and sorry for the late reply :

NSURL    *fileURL    =   [NSURL URLWithString:@"file  url from the internet "];
    MPMoviePlayerViewController *moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];

    [moviePlayerController.moviePlayer setFullscreen:YES animated:YES];
    [moviePlayerController.moviePlayer.view setFrame: self.view.bounds];
    [moviePlayerController.moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
    [moviePlayerController.moviePlayer setMovieSourceType:MPMovieSourceTypeFile];

    [self presentMoviePlayerViewControllerAnimated:moviePlayerController];
    [moviePlayerController.moviePlayer prepareToPlay];
    [moviePlayerController.moviePlayer play];
Iphone User
  • 1,930
  • 2
  • 17
  • 26