MPMoviePlayerController stops playing after a few seconds

Luna picture Luna · Sep 24, 2012 · Viewed 13.2k times · Source

MPMoviePlayerController stops playing after a few seconds, this is the code I'm using:

NSString *urlAddress = @"http://67.159.28.74:8730";
NSURL *url = [NSURL URLWithString:urlAddress];

MPMoviePlayerController *player = [[MPMoviePlayerController alloc]initWithContentURL:url];
player.movieSourceType = MPMovieSourceTypeStreaming;

player.view.hidden = NO;
[self.view addSubview:player.view];
[player prepareToPlay];

if(player){
    [player play];
}

The error im getting in the console is:

2012-09-23 18:07:56.618 Reader[696:c07] [MPAVController] Autoplay: Disabling autoplay for pause

2012-09-23 18:07:56.619 Reader[696:c07] [MPAVController] Autoplay: Disabling autoplay

2012-09-23 18:07:56.638 Reader[696:c07] [MPAVController] Autoplay: Disabling autoplay for pause

2012-09-23 18:07:56.638 Reader[696:c07] [MPAVController] Autoplay: Disabling autoplay

2012-09-23 18:07:56.643 Reader[696:c07] [MPAVController] Autoplay: Enabling autoplay

2012-09-23 18:07:56.645 Reader[696:c07] [MPAVController] Autoplay: Likely to keep up or full buffer: 0

2012-09-23 18:07:56.646 Reader[696:c07] [MPAVController] Autoplay: Skipping autoplay, not enough buffered to keep up.

2012-09-23 18:07:56.648 Reader[696:c07] [MPAVController] Autoplay: Likely to keep up or full buffer: 0

2012-09-23 18:07:56.648 Reader[696:c07] [MPAVController] Autoplay: Skipping autoplay, not enough buffered to keep up.

2012-09-23 18:07:56.650 Reader[696:c07] [MPAVController] Autoplay: Enabling autoplay

2012-09-23 18:07:56.652 Reader[696:c07] [MPCloudAssetDownloadController] Prioritization requested for media item ID: 0

2012-09-23 18:07:58.746 Reader[696:c07] [MPAVController] Autoplay: Likely to keep up or full buffer: 0

2012-09-23 18:07:58.746 Reader[696:c07] [MPAVController] Autoplay: Skipping autoplay, not enough buffered to keep up.

2012-09-23 18:07:58.747 Reader[696:c07] [MPAVController] Autoplay: _streamLikelyToKeepUp: 0 -> 1

2012-09-23 18:07:58.748 Reader[696:c07] [MPAVController] Autoplay: Likely to keep up or full buffer: 1

2012-09-23 18:07:58.748 Reader[696:c07] [MPAVController] Autoplay: Enabling autoplay`

Answer

Luna picture Luna · Sep 26, 2012

solved it:

I turned my MPMoviePlayerController into a property:

//add in header

@property (strong,nonatomic) MPMoviePlayerController *myPlayer;

//add in .m file

- (IBAction)playStream:(id)sender {
    NSString *urlAddress = @"http://67.159.28.74:8730";
    NSURL *url = [NSURL URLWithString:urlAddress];

    MPMoviePlayerController *player = [[MPMoviePlayerController alloc]initWithContentURL:url];
    [player prepareToPlay];
    //Remember you have to add MediaPlayer.framework to your project
    /*[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:player];*/

    player.movieSourceType = MPMovieSourceTypeStreaming;



    player.view.hidden = YES;

    self.myPlayer = player;

    [self.view addSubview:self.myPlayer.view];


    if(player){
      [self.myPlayer play];
    }
}