Support audio mix modes

This commit is contained in:
Tiago Koji Castro Shibata
2017-06-02 19:35:58 -03:00
parent a11adeea4a
commit 4c145e8c13
7 changed files with 94 additions and 0 deletions
+34
View File
@@ -26,6 +26,7 @@
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioServices.h>
#import <AVFoundation/AVFoundation.h>
#include <vector>
@@ -344,6 +345,39 @@ void vibrate()
}
}
void setAudioMixWithOthers(bool mixMode, bool playMuted)
{
@autoreleasepool
{
NSError* err;
if (mixMode)
{
if (playMuted)
{
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:&err];
}
else
{
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&err];
}
}
else
{
if (playMuted)
{
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&err];
}
}
if (err != nil)
NSLog(@"Error in AVAudioSession setCategory: %@", [err localizedDescription]);
}
}
bool audioShouldBeSilenced()
{
return [[AVAudioSession sharedInstance] secondaryAudioShouldBeSilencedHint];
}
} // ios
} // love