Skip to content

Commit

Permalink
[Video] Audio duck off main thread (#4926)
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok authored Aug 13, 2024
1 parent 3c04d9b commit 1fce7a7
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,26 @@ public class ExpoPlatformInfoModule: Module {

Function("setAudioCategory") { (audioCategoryString: String) in
let audioCategory = AVAudioSession.Category(rawValue: audioCategoryString)
try? AVAudioSession.sharedInstance().setCategory(audioCategory)

DispatchQueue.global(qos: .background).async {
try? AVAudioSession.sharedInstance().setCategory(audioCategory)
}
}

Function("setAudioActive") { (active: Bool) in
if active {
try? AVAudioSession.sharedInstance().setActive(true)
DispatchQueue.global(qos: .background).async {
try? AVAudioSession.sharedInstance().setActive(true)
}
} else {
try? AVAudioSession
.sharedInstance()
.setActive(
false,
options: [.notifyOthersOnDeactivation]
)
DispatchQueue.global(qos: .background).async {
try? AVAudioSession
.sharedInstance()
.setActive(
false,
options: [.notifyOthersOnDeactivation]
)
}
}
}
}
Expand Down

0 comments on commit 1fce7a7

Please sign in to comment.