From 1acae68ab4912c53a689d945d72addfed8737499 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Fri, 23 Oct 2015 09:42:43 +0300 Subject: [PATCH] iOS. Changing TTS volume all the time MAPS.ME is in foreground. Recovering playing background music after TTS notification. --- .../NavigationDashboard/Sound/MWMTextToSpeech.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Sound/MWMTextToSpeech.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Sound/MWMTextToSpeech.mm index f94a2314a7..2e83c4a241 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Sound/MWMTextToSpeech.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Sound/MWMTextToSpeech.mm @@ -20,6 +20,14 @@ extern NSString * const kMwmTextToSpeechDisable = @"MWMTEXTTOSPEECH_DISABLE"; self = [super init]; if (self) { + // Activating audio session. + NSError * err = nil; + AVAudioSession * audioSession = [AVAudioSession sharedInstance]; + if (![audioSession setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:&err]) + LOG(LWARNING, ("[ setCategory]] error.", [err localizedDescription])); + if (![audioSession setActive:YES error:&err]) + LOG(LWARNING, ("[[AVAudioSession sharedInstance] setActive]] error.", [err localizedDescription])); + // Before 9.0 version iOS has an issue with speechRate. AVSpeechUtteranceDefaultSpeechRate does not work correctly. // It's a work around for iOS 7.x and 8.x. self.speechRate = isIOSVersionLessThan(@"7.1.1") ? 0.3 : (isIOSVersionLessThan(@"9.0.0") ? 0.15 : AVSpeechUtteranceDefaultSpeechRate);