mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
Support audio mix modes
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user