logo
On this page

Turn off cam and mic when joining meeting


When starting a conference, the Video Conference Kit (ZegoUIKitPrebuiltVideoConference) turns on the camera, and microphone, and uses the speaker as the audio output device by default.

To change this default configuration, for example, turn off the camera when you start a conference or don't use the speaker (If the speaker is not used, the system's default audio output device, such as ear speaker, headset, Bluetooth, etc., will be used.), you can modify the following configurations:

  • turnOnCameraWhenJoining: Whether to turn on the camera when the conference starts. true: turn on (by default). false: turn off.
  • turnOnMicrophoneWhenJoining: Whether to turn on the camera when the conference starts. true: turn on (by default). false: turn off.
  • useSpeakerWhenJoining: Whether to use the speaker when the conference starts. true: use the speaker (by default). false: use the system's default audio output device, such as an ear speaker, headset, Bluetooth, etc.

Here is the reference code:

Untitled
public class ConferenceActivity extends AppCompatActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video_conference);

    long appID = YourAppID;
    String appSign = YourAppSign;
    String userID = userID;
    String userName = userID;
    String conferenceID = "testConferenceID";

    // Modify your custom configurations here.
    ZegoUIKitPrebuiltVideoConferenceConfig config = new ZegoUIKitPrebuiltVideoConferenceConfig();
    ZegoLeaveConfirmDialogInfo leaveConfirmDialogInfo = new ZegoLeaveConfirmDialogInfo();
    config.turnOnCameraWhenJoining = false;
    config.turnOnMicrophoneWhenJoining = false;
    config.useSpeakerWhenJoining = true;

    ZegoUIKitPrebuiltVideoConferenceFragment fragment = ZegoUIKitPrebuiltVideoConferenceFragment
            .newInstance(appID, appSign, userID, userName, conferenceID, config);

    getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.fragment_container, fragment)
            .commitNow();
  }
}
1
Copied!