KVO on AudioSession isOtherAudioPlaying not working

I am trying to get notified when another sound is playing. I wanted to use KVO for this as it [[AVAudioSession sharedInstance] isOtherAudioPlaying]

is a property of the audio session.

My registration as an observer:

//start KVO on otherAudioIsPlaying
    [[AVAudioSession sharedInstance] addObserver:self
                                      forKeyPath:@"isOtherAudioPlaying"
                                         options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld)
                                         context:nil];

      

My corresponding method:

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
NSLog(@"observe fired");
}

      

Why doesn't it work? AVAudioSession must be KVO compliant if it responds to the valueForKey selector, right?

My audio recording is activated before registering as an observer. Also, the session is being asked kAudioSessionProperty_OverrideCategoryMixWithOthers

what is the reason why I am not getting regular interruptions, so maybe this is the problem?

Even the deprecated function doesn't work:

AudioSessionAddPropertyListener(kAudioSessionProperty_OtherAudioIsPlaying, otherAudioPlaying , (__bridge void *)(self));

But if I type multiple times [[AVAudioSession sharedInstance] isOtherAudiPlaying]

, the value changes as expected.

Thanks for any hints!

+3
ios audio key-value-observing avaudiosession


source to share


No one has answered this question yet

Check out similar questions:

310
Enterprise app deployment not working on iOS 7.1
154
Is there Key Value Observing (KVO) in Swift?
87
KVO and ARC how to remove Observer
nineteen
AVSpeechSynthesizer AudioSession error
6
GCD and KVO problems
3
Setting up a private audio session AVCaptureSession
1
not get correct current google map sdk iOS address
0
KVO keyPathsForValuesAffecting not working
0
The specific expression in the if condition causes a 7 second delay in execution
0
KVO with unknown observable until runtime



All Articles
Loading...
X
Show
Funny
Dev
Pics