MPMoviePlayerPlaybackDidFinishNotification gets called when it shouldn't

前端 未结 4 434
走了就别回头了
走了就别回头了 2021-02-06 13:19

According to Apple\'s MPMoviePlayerController doc:

MPMoviePlayerPlaybackDidFinishNotification - This notification is not sent in cases where the movie player is displayi

4条回答
  •  旧时难觅i
    2021-02-06 14:03

    I am using the following to do something when a movie is played all the way to the end:

    - (void)playbackDidFinish:(NSNotification*)notification
    {
        BOOL playbackEnded = ([[[notification userInfo] valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue] == MPMovieFinishReasonPlaybackEnded);
        BOOL endReached = (self.player.currentPlaybackTime == self.player.playableDuration);
    
        if (playbackEnded && endReached) {
            // Movie Ended
        }
    }
    

提交回复
热议问题