Search code examples
iosmpmovieplayercontroller

MPMovieplayercontroller automatically pauses while streaming and doesn't play again


I'm using MPMoviePlayerController to play my video from URL. Below is my code:

NSString* url = [[promotionalDetailResponse objectAtIndex:index] valueForKey:@"Url"];

        NSURL *streamURL = [NSURL URLWithString:url];
        mPlayerVC = [[MPMoviePlayerViewController alloc] initWithContentURL:streamURL];
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(moviePlaybackComplete:)
                                                     name:MPMoviePlayerPlaybackStateDidChangeNotification
                                                   object:nil];

        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(moviePlaybackComplete:)
                                                     name:MPMoviePlayerPlaybackDidFinishNotification
                                                   object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(moviePlaybackComplete:)
                                                     name:MPMoviePlayerWillExitFullscreenNotification
                                                   object:nil];


        mPlayerVC.moviePlayer.fullscreen=YES;
        mPlayerVC.moviePlayer.shouldAutoplay=YES;
        [self presentMoviePlayerViewControllerAnimated:mPlayerVC];

It pauses while streaming and doesn't play automatically. I have to play it manually. However, it should start playing automatically once streaming is done.


Solution

  • You should mention the source type as follow:

    mPlayerVC.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;