实现纯语音互动
在开始通话时,音视频通话 UIKit 默认打开摄像头和麦克风,并将扬声器作为音频输出设备。
如需更改此默认配置,例如在开始通话时关闭摄像头,或者不使用扬声器(如果不使用扬声器,则将使用系统的默认音频输出设备,如听筒、耳机、蓝牙等),您可以修改以下配置:
turnOnCameraWhenJoining
:通话开始时是否打开摄像头。true:打开(默认)。false:关闭。turnOnMicrophoneWhenJoining
:通话开始时是否打开麦克风。true:打开(默认)。false:关闭。useSpeakerWhenJoining
:通话开始时是否使用扬声器。true:使用扬声器(默认)。false:使用系统的默认音频输出设备,如听筒、耳机、蓝牙等。
以下是参考代码:
public class CallActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_call);
long appID = YourAppID;
String appSign = YourAppSign;
String userID = "userID";
String userName = "userName";
String callID = "testCallID";
// Modify your custom configurations here.
ZegoUIKitPrebuiltCallConfig config = ZegoUIKitPrebuiltCallConfig.oneOnOneVideoCall();
config.turnOnCameraWhenJoining = false;
config.turnOnMicrophoneWhenJoining = false;
config.useSpeakerWhenJoining = true;
ZegoUIKitPrebuiltCallFragment fragment = ZegoUIKitPrebuiltCallFragment
.newInstance(appID, appSign, callID, userID, userName, config);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container, fragment)
.commitNow();
}
}