Merge pull request #356 from bykoianko/ios-volume-control

iOS. Changing TTS volume all the time MAPS.ME is in foreground.
This commit is contained in:
Vlad Mihaylenko 2015-10-23 11:45:12 +03:00
commit 6de2c25ed7

View file

@ -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);