KVO AVAudioPlayer not working
I am trying to observe the "currentTime" property of AVAudioPlayer. But the method isn't even being called... I need it to set the position of a UISlider.. But it's not working. Here's 开发者_开发问答the relevant code:
[audioPlayer addObserver:self forKeyPath:@"currentTime" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:nil];
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
NSLog(@"%@", change);
}
Thanks.
I believe currentTime is not KVO compliant check the header.
In any event, you can just start a NSTimer at your desired frequency and update your UI that way.
精彩评论