I am adding an Audio session property listener for kAudioSessionProperty_AudioRouteChange and in the callback I want to call the takePicture function of UIImagePickerController. The problem is that I cannot access my picker in the callback.
I am initializing my picker in viewDidLoad. I have tried declaring the picker as both a private and public object and accessing with picker or self.picker but it always gives the "Use of undeclared identifier" error. I use this code to add the listener:
AudioSessionInitialize(nil, nil, nil, nil);
AudioSessionSetActive(true);
AudioSessionAddPropertyListener(
kAudioSessionProperty_AudioRouteChange,
applicationAudioRouteDidChange,
self);
This is my callback:
void applicationVolumeDidChange(void *inClientData,
AudioSessionPropertyID inID,
UInt32 inDataSize, const void *inData)
{
NSLog(@"Volume changed");
//[picker takePicture]; Error
}
I also declared an NSArray to see if this was the problem with UIImagePickerController only but the array also gives the same error.