[Video] Audio duck off main thread (#4926)

zio/stable
Hailey 2024-08-12 20:08:51 -07:00 committed by GitHub
parent 3c04d9bd84
commit 1fce7a793d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 8 deletions

View File

@ -10,13 +10,19 @@ public class ExpoPlatformInfoModule: Module {
Function("setAudioCategory") { (audioCategoryString: String) in Function("setAudioCategory") { (audioCategoryString: String) in
let audioCategory = AVAudioSession.Category(rawValue: audioCategoryString) let audioCategory = AVAudioSession.Category(rawValue: audioCategoryString)
DispatchQueue.global(qos: .background).async {
try? AVAudioSession.sharedInstance().setCategory(audioCategory) try? AVAudioSession.sharedInstance().setCategory(audioCategory)
} }
}
Function("setAudioActive") { (active: Bool) in Function("setAudioActive") { (active: Bool) in
if active { if active {
DispatchQueue.global(qos: .background).async {
try? AVAudioSession.sharedInstance().setActive(true) try? AVAudioSession.sharedInstance().setActive(true)
}
} else { } else {
DispatchQueue.global(qos: .background).async {
try? AVAudioSession try? AVAudioSession
.sharedInstance() .sharedInstance()
.setActive( .setActive(
@ -27,3 +33,4 @@ public class ExpoPlatformInfoModule: Module {
} }
} }
} }
}