From 01f42fe4591de28c2b76de4f9ae95e5d8761ddf6 Mon Sep 17 00:00:00 2001 From: Fernando Nazario Sousa Date: Wed, 12 Jun 2024 09:50:08 -0300 Subject: [PATCH] fix: pause spoken audio like podcast or audiobook --- ios/TextToSpeech/TextToSpeech.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ios/TextToSpeech/TextToSpeech.m b/ios/TextToSpeech/TextToSpeech.m index a258146..1e769cc 100644 --- a/ios/TextToSpeech/TextToSpeech.m +++ b/ios/TextToSpeech/TextToSpeech.m @@ -79,7 +79,13 @@ + (BOOL)requiresMainQueueSetup } if([_ignoreSilentSwitch isEqualToString:@"ignore"]) { - [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; + [[AVAudioSession sharedInstance] + setCategory:AVAudioSessionCategoryPlayback + mode:AVAudioSessionModeVoicePrompt + // This will pause a spoken audio like podcast or audiobook and duck the volume for music + options:AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers + error:nil + ]; } else if([_ignoreSilentSwitch isEqualToString:@"obey"]) { [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil]; }