flutter_tts
flutter_tts copied to clipboard
Background play and sound mix not working ( setSharedInstance() not working )
🐛 Bug Report
Expected behavior
await flutterTts.setSharedInstance(true);
await flutterTts.setIosAudioCategory(IosTextToSpeechAudioCategory.ambient,
[
IosTextToSpeechAudioCategoryOptions.allowBluetooth,
IosTextToSpeechAudioCategoryOptions.allowBluetoothA2DP,
IosTextToSpeechAudioCategoryOptions.mixWithOthers
],
IosTextToSpeechAudioMode.voicePrompt
);
above method doesn't work
import UIKit
import AVFAudio
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
let audioSession = AVAudioSession.sharedInstance()
do {
try audioSession.setCategory(AVAudioSession.Category.playback,mode: AVAudioSession.Mode.voicePrompt, options:[AVAudioSession.CategoryOptions.mixWithOthers,AVAudioSession.CategoryOptions.duckOthers] )
} catch {
print("Setting category to AVAudioSessionCategoryPlayback failed.")
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
I solved the background playback and other sounds and mixes by adding an audio session directly to ios native.
Configuration
Version: 3.5.3
Platform:
- [x] :iphone: iOS ( iOS 16 )
- [ ] :robot: Android
thanks mate~