1

我的视频在 IOS 8.3 及更早版本上播放良好。但在最近更新 IOS 8.4 视频播放器后停止工作。视频没有被播放,它会立即进入 MPMoviePlaybackComplete: 方法。

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];

有人可以告诉我如何解决这个问题吗?

4

1 回答 1

0

根据播放时间和可播放持续时间添加重置视频方法。

   - (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];
            }
        }
    }
于 2015-07-23T10:18:59.213 回答