This also supports timed audio. I'd like to notify the VO user when the timed audio has finished recording. When the duration is reached recording automatically stops and (void)audioRecorderDidFinishRecording:(AVAudioRecorder*)recorder successfully:(BOOL)flag is called. From there I call a function to stop the recording and to reset the UI. This is the same method that is called when the user toggles recording off. I can not get VO to speak the announcement. Since VO does re-speak the button label when the user toggles it, I assume that I am not in an incorrect audio session state. I removed setting the category on the AudioSession and just left it at the default. When I am debugging and I stop within the if (self.duration) clause, I do hear the UIAccessibilityAnnouncementNotification, but only once. I hope this is just something simple I am missing?
- (void) stopRecordingCleanup
{
[self.avRecorder stop];
// deactivate session so VO sounds can come through
[self.avSession setActive: NO error: nil];
//[self.avSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
[self.recordButton setImage: recordImage forState:UIControlStateNormal];
self.recordButton.accessibilityTraits |= [self accessibilityTraits];
// this clears out UIAccessibilityTraitStartsMediaSession
[self.recordingView setHidden:YES];
self.doneButton.enabled = YES;
if (self.duration) { // we were doing timed audio
// make sure this notification is supported
BOOL isUIAccessibilityAnnouncementNotification = (&UIAccessibilityAnnouncementNotification != NULL);
if (isUIAccessibilityAnnouncementNotification) {
// announce to voiceover users that timed recording is complete
NSString* announce = NSLocalizedString(@"timed recording complete",nil);
NSLog(@"announcement: %@", announce); // extra debuggin so I know I got the string
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, announce);
}
} else { // was not timed recording, user toggled record button
// this PostNotification will force VoiceOver to speak button label again to give VO users indication that recording has stopped
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
}
}