Car*_*s P 14

您无法将KVO添加到currentPlaybackTime,因为该属性未显式声明为KVO兼容.

相反,您可以尝试定期轮询播放器并存储位置,例如:

- (void) BeginPlayerPolling {
self.pollPlayerTimer = [NSTimer scheduledTimerWithTimeInterval:5
                                                       target:self 
                                                     selector:@selector(PollPlayerTimer_tick:)
                                                     userInfo:nil 
                                                      repeats:YES];  

}

- (void) PollPlayerTimer_tick:(NSObject *)sender {
// Store current playback position
if (player.playbackState == MPMoviePlaybackStatePlaying)
    lastRecordedPlaybackTime = player.currentPlaybackTime;
}

- (void) EndPlayerPolling {
if (pollPlayerTimer != nil)
{
    [pollPlayerTimer invalidate];
    self.pollPlayerTimer = nil;
}
}
Run Code Online (Sandbox Code Playgroud)