area-essentialsgood first issueplatform/iosproposal/open
Description
Description
I use built-in TTS in our fitness app to give users better experience during working out. On Android everything works correctly but on iOS running TTS stops user's music.
From what I have found, iOS requires: AVFoundation.AVAudioSessionCategoryOptions.MixWithOthers
Can you add something like this into SpeechOptions ?
Steps to Reproduce
- Start music player or radio on your iPhone
- From your maui app call
await TextToSpeech.Default.SpeakAsync("this text will stop music in background"); - Music stops
Link to public reproduction project repository
No response
Version with bug
9.0.21 SR2.1
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
No response
Did you find any workaround?
In Platforms->iOS create AudioSessionManager with:
using AVFoundation;
using Foundation;
public class AudioSessionManager
{
public static void ConfigureAudioSession()
{
var audioSession = AVAudioSession.SharedInstance();
NSError error;
audioSession.SetCategory(AVAudioSessionCategory.Playback, AVAudioSessionCategoryOptions.MixWithOthers, out error);
audioSession.SetActive(true, AVAudioSessionSetActiveOptions.NotifyOthersOnDeactivation, out error);
}
}
and initialize it in AppDelegate. In my case I did it in FinishedLaunching like:
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
AudioSessionManager.ConfigureAudioSession();
return base.FinishedLaunching(application, launchOptions);
}