-
Notifications
You must be signed in to change notification settings - Fork 2.3k
iOS audio playback behavior - requests for change #19197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Googled and didn't find much, but according to ChatGPT, something like this will do the trick: @import AVFoundation;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *error = nil;
BOOL success = [audioSession setCategory:AVAudioSessionCategoryAmbient withOptions:AVAudioSessionCategoryOptionMixWithOthers error:&error];
if (!success) {
NSLog(@"Failed to set audio session category: %@", error);
}
success = [audioSession setActive:YES error:&error];
if (!success) {
NSLog(@"Failed to activate audio session: %@", error);
}
return YES; Will try it soon. |
It seems the two goals are contradictory, so we need a setting. For apps to keep playing when silent mode is on, it cannot share the output with other apps using the mixwithothers flag. Also need to use the AVAudioSessionCategoryPlayback mode, not Ambient. |
OK, so my current idea for a design is two modes:
What are these called in other apps? When an external display is connected, we already switched to Exclusive mode, effectively. |
Delta has a rather complex audio manager that manually looks at the mute switch and adjusts volume accordingly, but always runs in mix mode: https://github.com/rileytestut/DeltaCore/blob/main/DeltaCore/Emulator%20Core/Audio/AudioManager.swift I think we can get pretty far with something much simpler like the above.. But eventually I suppose we might end up doing something similar, we'll see. |
Hm, actually there are three modes that are achievable:
Exclusive playback + respect silent mode doesn't seem to be possible. So maybe two checkboxes as UI isn't appropriate. EDIT: Actually, the fourth mode is possible, so no problem here. |
So, either using 2 checkboxes or a single dropdown with 3 options? |
I discovered that the fourth mode is actually possible. So I'm going with two checkboxes. |
I've gotten two requests of changes to audio behavior:
I assume these behaviors are just controlled by various flags to the CoreAudio API, so need to track down documentation and figure out what we want to set.
The text was updated successfully, but these errors were encountered: