Fix audio session

This commit is contained in:
Thomas Ricouard 2023-03-06 14:10:39 +01:00
parent 796f451f3a
commit 28230ba184
2 changed files with 3 additions and 1 deletions

View File

@ -270,7 +270,7 @@ class AppDelegate: NSObject, UIApplicationDelegate {
func application(_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool
{
try? AVAudioSession.sharedInstance().setCategory(.ambient, options: .mixWithOthers)
try? AVAudioSession.sharedInstance().setCategory(.ambient)
PushNotificationsService.shared.setAccounts(accounts: AppAccountsManager.shared.pushAccounts)
return true
}

View File

@ -22,6 +22,8 @@ public class SoundEffectManager {
public func playSound(of type: SoundEffect) {
guard userPreferences.soundEffectEnabled else { return }
if let url = Bundle.main.url(forResource: type.rawValue, withExtension: "wav") {
try? AVAudioSession.sharedInstance().setCategory(.ambient)
try? AVAudioSession.sharedInstance().setActive(true)
currentPlayer = try? .init(contentsOf: url)
currentPlayer?.prepareToPlay()
currentPlayer?.play()