实现纯语音互动
在开始通话时,音视频通话 UIKit 默认打开摄像头和麦克风,并将扬声器作为音频输出设备。
如需更改此默认配置,例如在开始通话时关闭摄像头,或者不使用扬声器(如果不使用扬声器,则将使用系统的默认音频输出设备,如听筒、耳机、蓝牙等),您可以修改以下配置:
turnOnCameraWhenJoining
:通话开始时是否打开摄像头。true:打开(默认)。false:关闭。turnOnMicrophoneWhenJoining
:通话开始时是否打开麦克风。true:打开(默认)。false:关闭。useSpeakerWhenJoining
:通话开始时是否使用扬声器。true:使用扬声器(默认)。false:使用系统的默认音频输出设备,如听筒、耳机、蓝牙等。
以下是参考代码:
class ViewController: UIViewController {
let selfUserID: String = "userID"
let selfUserName: String = "userName"
let yourAppID: UInt32 = YourAppID
let yourAppSign: String = YourAppSign
let callID: String = "testCallID"
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func makeNewCall(_ sender: Any) {
// 在此处修改您的自定义配置。
let config: ZegoUIKitPrebuiltCallConfig = ZegoUIKitPrebuiltCallConfig.oneOnOneVideoCall()
config.turnOnCameraWhenJoining = false;
config.turnOnMicrophoneWhenJoining = false;
config.useSpeakerWhenJoining = true;
let callVC = ZegoUIKitPrebuiltCallVC.init(yourAppID, appSign: yourAppSign, userID: selfUserID, userName: selfUserName ?? "", callID: callID, config: config)
callVC.modalPresentationStyle = .fullScreen
self.present(callVC, animated: true, completion: nil)
}
}