MPMoviePlayer如何在用户向前搜索时如何检测?

时间:2013-07-31 18:11:57

标签: ios mpmovieplayer

感谢您的帮助,我有一个电影播放器​​,我想阻止用户在电影中向前擦洗,但我不在乎他们是否倒退(倒带)。我正在检测播放状态何时发生变化,然后测试“MPMoviePlayerDidSeekingForward”

问题在于,无论方向如何,当我擦洗时,playbackState总是向前寻找。

由于各种原因,我无法制作自己的自定义播放器,我需要使用标准的MPMoviePlayer。

以下是代码:

- (void)moviePlayerPlaybackStateDidChangeNotificationReceived:(NSNotification *)notification {

    //movie playback has started go to full screen.

    if(_player.fullscreen == NO){
        _player.fullscreen = YES;
    }

    //prevent user from scrubbing through the movie

//    #ifdef DEBUG
//    
//       return;
//    #else

    if(_player.playbackState == MPMoviePlaybackStateSeekingForward){


        NSString *alertMessage = [NSString stringWithFormat:@"you are not allowed to skip the movies"

        UIAlertView *alert =
        [[UIAlertView alloc] initWithTitle: @"Warning"
                                   message: alertMessage
                                  delegate: self
                         cancelButtonTitle: @"Continue"
                         otherButtonTitles: @"Stop", nil];
        self.isShowing = YES;
        [alert show];

        [_player pause];
        _player.fullscreen = NO;
    }
   // #endif

1 个答案:

答案 0 :(得分:0)

您是否尝试放置[_player endSeeking]

if(_player.playbackState == MPMoviePlaybackStateSeekingForward){声明?