Start a conversation

Switch the camera for video call (Android)

It is possible to switch the camera from the front to the main one and vice versa during the video call.
Keep in mind that the front camera is used by default.

In order to implement this functionality, you need to use CameraSwitchHandler.

First of all, you need to create a VideoCapturer instance.
Java:

QBRTCCameraVideoCapturer videoCapturer = (QBRTCCameraVideoCapturer) currentSession.getMediaStreamManager().getVideoCapturer(); videoCapturer.switchCamera(cameraSwitchHandler);


Kotlin:

val videoCapturer = currentSession.mediaStreamManager.videoCapturer as QBRTCCameraVideoCapturer videoCapturer.switchCamera(cameraSwitchHandler)


After that, you will need to create a CameraSwitchHandler instance, which will handle the camera switching process with onCameraSwitchDone and onCameraSwitchError methods.


Java:

CameraVideoCapturer.CameraSwitchHandler cameraSwitchHandler = new CameraVideoCapturer.CameraSwitchHandler() {
    @Override
    public void onCameraSwitchDone(boolean b) {


//   Your code here


    }

    @Override
    public void onCameraSwitchError(String s) {


//   Your code here


    }
};

Kotlin:

val cameraSwitchHandler = object : CameraVideoCapturer.CameraSwitchHandler {
    override fun onCameraSwitchDone(b: Boolean?) {

//   Your code here

    }

    override fun onCameraSwitchError(s: String?) {

//   Your code here

    }
}

You may use our documentation page for reference:
https://docs.quickblox.com/docs/android-video-calling-advanced#switch-camera

Congratulations! Now your users are able to switch the camera during the video call!         


 If you have any additional questions, feel free to submit a ticket to our Support team and we will help with all your efforts.

Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Maksym Pidhorbunskyi

  2. Posted
  3. Updated

Comments