# 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. ```kotlin 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) ``` ```java List 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`. ```kotlin ZoomVideoSDK.getInstance().videoHelper.startVideoCanvasPreview(video_view, ZoomVideoSDKVideoAspect.ZoomVideoSDKVideoAspect_Full_Filled) ``` ```java 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. 1. Override the following two callbacks in `ZoomVideoSDKDelegate`. For example, when the volume changes (available levels are from 0 to 10). ```kotlin override fun onMicSpeakerVolumeChanged(micVolume: Int, speakerVolume: Int) { //TO DO } override fun onTestMicStatusChanged(status: ZoomVideoSDKTestMicStatus) { //TO DO } ``` ```java @Override public void onMicSpeakerVolumeChanged(int micVolume, int speakerVolume) { //TO DO } @Override public void onTestMicStatusChanged(ZoomVideoSDKTestMicStatus status) { //TO DO } ``` 2. Start a microphone testing session. ```kotlin // Use ZoomVideoSDKTestAudioDeviceHelper start the microphone test. val testAudioDeviceHelper = ZoomVideoSDK.getInstance().testAudioDeviceHelper val ret: Int = testAudioDeviceHelper.startMicTest() ``` ```java // Use ZoomVideoSDKTestAudioDeviceHelper start the microphone test. ZoomVideoSDKTestAudioDeviceHelper testAudioDeviceHelper = ZoomVideoSDK.getInstance().getTestAudioDeviceHelper(); int ret = testAudioDeviceHelper.startMicTest(); ``` 3. Stop the microphone testing session ```kotlin val ret: Int = testAudioDeviceHelper.stopMicTest() ``` ```java 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. 1. Add the MP3 file to your project. 2. 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 a `ZoomVideoSDKExtendParams`, and add the MP3 file path under its `speakerTestFilePath` variable. Be sure that the path is valid and not null. ```kotlin val params = ZoomVideoSDKInitParams() val extendParams = ZoomVideoSDKExtendParams() extendParams.speakerTestFilePath = "/sdcard/Android/data/com.example.videosdkonandroidfromscratch/example.mp3" ``` ```java ZoomVideoSDKInitParams params = new ZoomVideoSDKInitParams(); ZoomVideoSDKExtendParams extendParams = new ZoomVideoSDKExtendParams(); extendParams.speakerTestFilePath = "/sdcard/Android/data/com.example.videosdkonandroidfromscratch/test.mp3"; ``` 3. Under the same `ZoomVideoSDKInitParams`, which is used to set the domain and enable the log, add the `ZoomVideoSDKExtendParams` variable under its `extendParam`. Then get the helper to test the speaker. ```kotlin params.extendParam = extendParams val testAudioDeviceHelper = ZoomVideoSDK.getInstance().testAudioDeviceHelper ``` ```java params.extendParam = extendParams; ZoomVideoSDKTestAudioDeviceHelper testAudioDeviceHelper = ZoomVideoSDK.getInstance().getTestAudioDeviceHelper(); ``` 4. Start the speaker test. You'll receive the callback `onMicSpeakerVolumeChanged` with the speaker volume if it's successful. ```kotlin val ret: Int = testAudioDeviceHelper.startSpeakerTest() ``` ```java ZoomVideoSDKErrors ret = testAudioDeviceHelper.startSpeakerTest(); ``` 5. Stop the speaker test. ```kotlin val ret: Int = testAudioDeviceHelper.stopSpeakerTest() ``` ```java ZoomVideoSDKErrors ret = testAudioDeviceHelper.stopSpeakerTest(); ```