0

Hi to all i've got a strange behavior with an MPMoviePlayerController

the odds time i play the video it works... the evens no!

as said here MPMoviePlayerController will play once, then throw an error the problem could be the url, but i'm not able to find a solution..

Here is my code

NSURL *myUrl = [[NSURL alloc] initWithString:CDNRequest];

    moviecontroller = [[MMRMovieViewController alloc] initWithContentURL:myUrl];

    [[moviecontroller moviePlayer] setScalingMode:MPMovieScalingModeAspectFit];
    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(playbackFinished:) 
                                                 name:MPMoviePlayerPlaybackDidFinishNotification object:[moviecontroller moviePlayer]];
    [self moviecontroller]; 

MMRMovieViewController is a view controller which just extends MPMoviePlayerViewController. and here is the playbackFinished method

- (void)playbackFinished:(NSNotification*)notification {
MPMoviePlayerController *moviePlayer = [notification object];
NSNumber* reason = [[notification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
switch ([reason intValue]) {
    case MPMovieFinishReasonPlaybackEnded:
        [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
        NSLog(@"playback ended");
        break;
    case MPMovieFinishReasonPlaybackError:
        [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
        NSLog(@"playback error");
        NSError* error = [[notification userInfo] valueForKey:@"error"];
        NSLog(@"error=%@", error);

        break;
    case MPMovieFinishReasonUserExited:
        [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
        NSLog(@"user exited");
        break;
    default:
        [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
        break;
}
if (moviePlayer == TRUE) {
    [moviePlayer setFullscreen:NO animated:YES];
}

[moviePlayer stop];
[moviePlayer removeFromSuperview];
moviePlayer = nil;
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}

The error log says: "rror = "Error Domain=MediaPlayerErrorDomain Code=-12847 \"This movie format is not supported.\" UserInfo=0x5b60030 {NSLocalizedDescription=This movie format is not supported.}" But sometimes it goes! so it can't be this the reason!

Any help is appreciated!

Thank You!

Community
  • 1
  • 1
Gianluca
  • 2,379
  • 3
  • 25
  • 41
  • Set a breakpoint/NSLog statements and print out the value of CDNRequest. It's possible that whatever logic you use to set the CDNRequest variable is setting it to a bad value every other time through. – jmstone617 Apr 01 '12 at 23:19
  • which format for play the video..! – Dinesh Apr 02 '12 at 05:18
  • this is how it looks like a CDNRequest value: http://cdnselector.xuniplay.fdnames.com/getCDN.aspx?streamid=293655&redirect=true NSLog prints this value also when the video doesn't play. The format should be m3u8 – Gianluca Apr 02 '12 at 08:16
  • may be it related to this link [How to play movie files with no file extension on iOS with MPMoviePlayerController or AVPlayer?] http://stackoverflow.com/questions/5501670/how-to-play-movie-files-with-no-file-extension-on-ios-with-mpmovieplayercontroll – maheswaran Apr 02 '12 at 10:38

1 Answers1

0

This certainly is a stream issue.

Options:

  • Video format is incompatible -- You kind of rule this out

  • Video delivery server setup is defective -- You should use Charles or a similar HTTP proxy to analyze the traffic

To rule out any issues with your own code, try to enter the stream URL within the mobile Safari browser. If that one fails to play, then it is not a client/code related issue.

Till
  • 27,559
  • 13
  • 88
  • 122