forked from organicmaps/organicmaps
[ios] Fixed bug with changing volume while app in foreground.
This commit is contained in:
parent
d8f6468ec2
commit
df36ddffbe
3 changed files with 14 additions and 10 deletions
|
@ -4,7 +4,7 @@
|
|||
@interface MWMTextToSpeech : NSObject
|
||||
|
||||
+ (instancetype)tts;
|
||||
|
||||
+ (void)activateAudioSession;
|
||||
- (vector<std::pair<string, string>>)availableLanguages;
|
||||
- (NSString *)savedLanguage;
|
||||
- (void)setNotificationsLocale:(NSString *)locale;
|
||||
|
|
|
@ -37,18 +37,9 @@ extern NSString * const kUserDafaultsNeedToEnableTTS = @"UserDefaultsNeedToEnabl
|
|||
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]));
|
||||
|
||||
_availableLanguages = availableLanguages();
|
||||
|
||||
NSString * saved = self.savedLanguage;
|
||||
|
||||
string preferedLanguage;
|
||||
if (saved.length)
|
||||
preferedLanguage = saved.UTF8String;
|
||||
|
@ -67,6 +58,17 @@ extern NSString * const kUserDafaultsNeedToEnableTTS = @"UserDefaultsNeedToEnabl
|
|||
return self;
|
||||
}
|
||||
|
||||
+ (void)activateAudioSession
|
||||
{
|
||||
// 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]));
|
||||
}
|
||||
|
||||
- (vector<pair<string, string>>)availableLanguages
|
||||
{
|
||||
return _availableLanguages;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#import "MapsAppDelegate.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MWMAlertViewController.h"
|
||||
#import "MWMTextToSpeech.h"
|
||||
#import "MWMWatchEventInfo.h"
|
||||
#import "Preferences.h"
|
||||
#import "RouteState.h"
|
||||
|
@ -210,6 +211,7 @@ void InitLocalizedStrings()
|
|||
f.GetLocationState()->InvalidatePosition();
|
||||
|
||||
[self enableTTSForTheFirstTime];
|
||||
[MWMTextToSpeech activateAudioSession];
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue