diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-08-14 20:21:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-14 20:21:14 +0100 |
commit | 21e214c23579e5ca45fed3ec563d4010e37562a2 (patch) | |
tree | 87f6151ee2d9988f8af79449e0463c735d667b9f /modules | |
parent | 26d3777ecc7192835f4b14a9fad775d8044e29f9 (diff) | |
download | voidsky-21e214c23579e5ca45fed3ec563d4010e37562a2.tar.zst |
[Video] set audio category to ambient every time a new player is made (#4934)
* set auto category to ambient every time a new player is made * mute on foregrounding * remember previous state --------- Co-authored-by: Samuel Newman <10959775+mozzius@users.noreply.github.com> Co-authored-by: Hailey <me@haileyok.com>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/expo-bluesky-swiss-army/ios/PlatformInfo/ExpoPlatformInfoModule.swift | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/modules/expo-bluesky-swiss-army/ios/PlatformInfo/ExpoPlatformInfoModule.swift b/modules/expo-bluesky-swiss-army/ios/PlatformInfo/ExpoPlatformInfoModule.swift index cae4b983d..02bf5c662 100644 --- a/modules/expo-bluesky-swiss-army/ios/PlatformInfo/ExpoPlatformInfoModule.swift +++ b/modules/expo-bluesky-swiss-army/ios/PlatformInfo/ExpoPlatformInfoModule.swift @@ -1,6 +1,9 @@ import ExpoModulesCore public class ExpoPlatformInfoModule: Module { + private var prevAudioActive: Bool? + private var prevAudioCategory: AVAudioSession.Category? + public func definition() -> ModuleDefinition { Name("ExpoPlatformInfo") @@ -10,13 +13,20 @@ public class ExpoPlatformInfoModule: Module { Function("setAudioCategory") { (audioCategoryString: String) in let audioCategory = AVAudioSession.Category(rawValue: audioCategoryString) - + if audioCategory == self.prevAudioCategory { + return + } + self.prevAudioCategory = audioCategory DispatchQueue.global(qos: .background).async { try? AVAudioSession.sharedInstance().setCategory(audioCategory) } } Function("setAudioActive") { (active: Bool) in + if active == self.prevAudioActive { + return + } + self.prevAudioActive = active if active { DispatchQueue.global(qos: .background).async { try? AVAudioSession.sharedInstance().setActive(true) |