5

Estoy tratando de observar la propiedad "currentTime" de AVAudioPlayer. Pero el método ni siquiera se llama ... Lo necesito para establecer la posición de un UISlider ... Pero no está funcionando. Aquí está el código correspondiente:KVO AVAudioPlayer no funciona

[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.

Respuesta

5

Creo que currentTime no es compatible con KVO, compruebe el encabezado.

En cualquier caso, puede iniciar un NSTimer a la frecuencia deseada y actualizar su UI de esa manera.

Cuestiones relacionadas