首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MPMoviePlayerViewController无法播放iOS8.4的视频

MPMoviePlayerViewController无法播放iOS8.4的视频
EN

Stack Overflow用户
提问于 2015-07-09 16:07:52
回答 1查看 552关注 0票数 1

我的视频在IOS 8.3和更早的版本上播放得很好。但在IOS 8.4最近的更新之后,视频播放器停止了工作。视频不会被播放,它会立即转到MPMoviePlaybackComplete: method。

代码语言:javascript
复制
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];

谁能告诉我如何解决这个问题?

EN

回答 1

Stack Overflow用户

发布于 2015-07-23 18:18:59

添加您的基于playbacktime和playableduration的重置视频方法。

代码语言:javascript
复制
   - (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];
            }
        }
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31311636

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档