Preview
Before and after joining a session, you can give users a preview of their video and audio by starting the camera and microphone locally. The local video and audio can be accessed through IZoomVideoSDKVideoHelper and IZoomVideoSDKTestAudioDeviceHelper respectively.
Preview camera
To preview a camera on Android, you will need a video UI control to stream YUV420 raw data frames into the UI control as a video.
val cameras = ZoomVideoSDK.getInstance().videoHelper.cameraList
// Get ID of selected camera
val deviceId = cameras[0].deviceId
// Start preview and handle the callback in a ZoomVideoSDKRawDataPipeDelegate instance
ZoomVideoSDK.getInstance().videoHelper.startVideoPreview(this)
List<ZoomVideoSDKCameraDevice> cameras = ZoomVideoSDK.getInstance().getVideoHelper().getCameraList();
// Get ID of selected camera
String deviceID = cameras.get(0).getDeviceId();
// Start [review and handle the callback in a ZoomVideoSDKRawDataPipeDelegate instance
ZoomVideoSDK.getInstance().getVideoHelper().startVideoPreview(this);
Alternatively on Android, there is a ZoomVideoSDKVideoView control provided. If you wish to use this control, add it to your layout, name it (for example, video_view), and use startVideoCanvasPreview instead of startVideoPreview.
ZoomVideoSDK.getInstance().videoHelper.startVideoCanvasPreview(video_view, ZoomVideoSDKVideoAspect.ZoomVideoSDKVideoAspect_Full_Filled)
ZoomVideoSDK.getInstance().getVideoHelper().startVideoCanvasPreview(video_view, ZoomVideoSDKVideoAspect.ZoomVideoSDKVideoAspect_Full_Filled)
Preview audio
See the following restrictions and prerequisites for testing the microphone and speakers.
Restriction
Users can only test their audio after joining a session with the SDK, for example, if they're in a waiting room.
Prerequisites
- Video SDK Account
- Microphone, such as the built in microphone, a USB microphone (if supported), or an inline microphone on headphones
- Speaker or headphones
Preview microphone
Note: Microphone playback only works after users join a session. However, you can still get volume changes before and after joining a session.
-
Override the following two callbacks in
ZoomVideoSDKDelegate. For example, when the volume changes (available levels are from 0 to 10).override fun onMicSpeakerVolumeChanged(micVolume: Int, speakerVolume: Int) { //TO DO } override fun onTestMicStatusChanged(status: ZoomVideoSDKTestMicStatus) { //TO DO }@Override public void onMicSpeakerVolumeChanged(int micVolume, int speakerVolume) { //TO DO } @Override public void onTestMicStatusChanged(ZoomVideoSDKTestMicStatus status) { //TO DO } -
Start a microphone testing session.
// Use ZoomVideoSDKTestAudioDeviceHelper start the microphone test. val testAudioDeviceHelper = ZoomVideoSDK.getInstance().testAudioDeviceHelper val ret: Int = testAudioDeviceHelper.startMicTest()// Use ZoomVideoSDKTestAudioDeviceHelper start the microphone test. ZoomVideoSDKTestAudioDeviceHelper testAudioDeviceHelper = ZoomVideoSDK.getInstance().getTestAudioDeviceHelper(); int ret = testAudioDeviceHelper.startMicTest(); -
Stop the microphone testing session
val ret: Int = testAudioDeviceHelper.stopMicTest()int ret = testAudioDeviceHelper.stopMicTest();
Preview speakers
Zoom Video SDK currently only supports MP3 files for speaker tests. The size of the file cannot exceed 1 MB. You must add your own MP3 file and make it accessible from the user's device when they run the test. Follow these steps to configure and run the test.
-
Add the MP3 file to your project.
-
Ensure that the user's device can access the MP3 file to use for the test. Define the speaker test audio file path in
ZoomVideoSDKInitParams, create aZoomVideoSDKExtendParams, and add the MP3 file path under itsspeakerTestFilePathvariable. Be sure that the path is valid and not null.val params = ZoomVideoSDKInitParams() val extendParams = ZoomVideoSDKExtendParams() extendParams.speakerTestFilePath = "/sdcard/Android/data/com.example.videosdkonandroidfromscratch/example.mp3"ZoomVideoSDKInitParams params = new ZoomVideoSDKInitParams(); ZoomVideoSDKExtendParams extendParams = new ZoomVideoSDKExtendParams(); extendParams.speakerTestFilePath = "/sdcard/Android/data/com.example.videosdkonandroidfromscratch/test.mp3"; -
Under the same
ZoomVideoSDKInitParams, which is used to set the domain and enable the log, add theZoomVideoSDKExtendParamsvariable under itsextendParam. Then get the helper to test the speaker.params.extendParam = extendParams val testAudioDeviceHelper = ZoomVideoSDK.getInstance().testAudioDeviceHelperparams.extendParam = extendParams; ZoomVideoSDKTestAudioDeviceHelper testAudioDeviceHelper = ZoomVideoSDK.getInstance().getTestAudioDeviceHelper(); -
Start the speaker test. You'll receive the callback
onMicSpeakerVolumeChangedwith the speaker volume if it's successful.val ret: Int = testAudioDeviceHelper.startSpeakerTest()ZoomVideoSDKErrors ret = testAudioDeviceHelper.startSpeakerTest(); -
Stop the speaker test.
val ret: Int = testAudioDeviceHelper.stopSpeakerTest()ZoomVideoSDKErrors ret = testAudioDeviceHelper.stopSpeakerTest();