Improve audio session setup

This commit is contained in:
Tiago Jacobs 2022-05-16 19:59:33 -03:00
parent 37590129c1
commit be6ef684c5
3 changed files with 11 additions and 3 deletions

View File

@ -110,7 +110,9 @@ open class AudioWebRTCClient: NSObject {
do {
try self.rtcAudioSession.setCategory(AVAudioSession.Category.playAndRecord.rawValue)
try self.rtcAudioSession.session.setCategory(AVAudioSession.Category.playAndRecord, options: [AVAudioSession.CategoryOptions.mixWithOthers])
try self.rtcAudioSession.setMode(AVAudioSession.Mode.voiceChat.rawValue)
} catch let error {
debugPrint("Error changing AVAudioSession category: \(error)")
}

View File

@ -8,6 +8,7 @@
import Foundation
import os
import bigbluebutton_mobile_sdk_common
import AVFAudio
open class BigBlueButtonSDK: NSObject {
// Logger (these messages are displayed in the console application)
@ -91,6 +92,13 @@ open class BigBlueButtonSDK: NSObject {
logger.info("Detected a change in userDefaults for key broadcastFinished")
ReactNativeEventEmitter.emitter.sendEvent(withName: ReactNativeEventEmitter.EVENT.onBroadcastFinished.rawValue, body: nil)
}
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback, options: [AVAudioSession.CategoryOptions.mixWithOthers])
try AVAudioSession.sharedInstance().setPrefersNoInterruptionsFromSystemAlerts(true)
} catch let error {
logger.error("Error configuring audio session \(error.localizedDescription)")
}
}
public static func getBroadcastExtensionBundleId() -> String {
@ -107,6 +115,7 @@ open class BigBlueButtonSDK: NSObject {
}
public static func onAppTerminated(){
logger.info("onAppTerminated called")
BBBSharedData
.getUserDefaults(appGroupName: self.appGroupName)
.set(BBBSharedData.generatePayload(), forKey: BBBSharedData.SharedData.onApplicationTerminated)

View File

@ -22,10 +22,7 @@ class ScreenShareServiceManager: NSObject {
Task.init {
do{
try audioSession.setCategory(AVAudioSession.Category.playback, options: [AVAudioSession.CategoryOptions.mixWithOthers])
try audioSession.setPrefersNoInterruptionsFromSystemAlerts(true)
try audioSession.setActive(true)
}catch{
print(error)
}