MPMoviePlayerViewController not playing videos for IOS 8.4
Asked Answered
H

1

1

My videos are playing well for IOS 8.3 and earlier versions. But after a recent update of IOS 8.4 Video Player stopped working. Videos are not getting played and immediately it's going to MPMoviePlaybackComplete: method.

Here is my code :

     self.player = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];

    [self.player.moviePlayer setFullscreen:YES animated:YES];

      if(subtitlesPathStr){
    [self.player.moviePlayer openSRTFileAtPath:subtitlesPathStr
                                       completion:^(BOOL finished) {

                                           // Activate subtitles

                                           [self.player.moviePlayer showSubtitles];
    [self.navigationController presentMoviePlayerViewControllerAnimated:self.player];

                                       } failure:^(NSError *error) {

                                   NSLog(@"Error: %@", error.description);
           }

             ];
        }else [self.navigationController presentMoviePlayerViewControllerAnimated:self.player];

     [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(MPMoviePlayerLoadStateDidChange:)
                                                     name:MPMoviePlayerLoadStateDidChangeNotification
                                                   object:nil];

        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(MPMoviePlayerDidEnterFullscreenNotification:)
                                                     name:MPMoviePlayerDidEnterFullscreenNotification
                                                   object:nil];

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

Can somebody tell me how to solve this issue ?

Heavenly answered 9/7, 2015 at 8:7 Comment(1)
Same issue in our appsCherian
P
0

Add your reset video method based on playbacktime and playableduration.

   - (void)playbackDidFinish:(NSNotification*)aNotification {
        MPMoviePlayerController *moviePlayer = aNotification.object;
        NSNumber *reason = [aNotification.userInfo objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
        if ([reason intValue] == MPMovieFinishReasonPlaybackEnded) {
            if (moviePlayer.currentPlaybackTime == moviePlayer.playableDuration) {
                [moviePlayer stop];
            }
        }
    }
Petey answered 23/7, 2015 at 10:18 Comment(1)
I am suffering from the same issue, In my case video is playing fine first time , but when I create new video and try to reload with new video, app crashing. code was working fine in older then 8.4 , not working in 8.4. please let me know how can i reset videoHamate

© 2022 - 2024 — McMap. All rights reserved.