[Video] Audio duck off main thread (#4926)
parent
3c04d9bd84
commit
1fce7a793d
|
@ -10,19 +10,26 @@ 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)
|
||||||
try? AVAudioSession.sharedInstance().setCategory(audioCategory)
|
|
||||||
|
DispatchQueue.global(qos: .background).async {
|
||||||
|
try? AVAudioSession.sharedInstance().setCategory(audioCategory)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function("setAudioActive") { (active: Bool) in
|
Function("setAudioActive") { (active: Bool) in
|
||||||
if active {
|
if active {
|
||||||
try? AVAudioSession.sharedInstance().setActive(true)
|
DispatchQueue.global(qos: .background).async {
|
||||||
|
try? AVAudioSession.sharedInstance().setActive(true)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
try? AVAudioSession
|
DispatchQueue.global(qos: .background).async {
|
||||||
.sharedInstance()
|
try? AVAudioSession
|
||||||
.setActive(
|
.sharedInstance()
|
||||||
false,
|
.setActive(
|
||||||
options: [.notifyOthersOnDeactivation]
|
false,
|
||||||
)
|
options: [.notifyOthersOnDeactivation]
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue