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.

Note: Microphone playback only works after users join a session. However, you can still get volume changes before and after joining a session.

Preview camera

To preview a camera, you will first need to have a view defined in order to subscribe to it and you can do so using the video helper interface.

if let videoHelper = ZoomVideoSDK.shareInstance()?.getVideoHelper() {
    // Start preview: viewForVideoPreview is an example of an UIView defined earlier
    videoHelper.startVideoCanvasPreview(self.viewForVideoPreview, andAspectMode: .panAndScan)
    // Stop preview
    videoHelper.stopVideoCanvasPreview(viewForVideoPreview)
}
ZoomVideoSDKVideoHelper *videoHelper = [[ZoomVideoSDK shareInstance] getVideoHelper];
// Start preview: viewForVideoPreview is an example of an UIView defined earlier
[videoHelper startVideoCanvasPreview:viewForVideoPreview andAspectMode: ZoomVideoSDKVideoAspect_PanAndScan];
// Stop preview
[videoHelper stopVideoCanvasPreview:viewForVideoPreview];

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

  1. Override the following two callbacks in ZoomVideoSDKDelegate. For example, when the volume changes (available levels are from 0 to 10). See step 3 and 4 for details.

    func onMicSpeakerVolumeChanged(_ micVolume: Int32, speakerVolume: Int32) {
            //TO DO
    }
    func onTestMicStatusChanged(_ status: ZoomVideoSDKTestMicStatus) {
            //TO DO
    }
    
    - (void)onMicSpeakerVolumeChanged:(int)micVolume speakerVolume:(int)speakerVolume {
    	//TO DO
    }
    - (void)onTestMicStatusChanged:(ZoomVideoSDKTestMicStatus)status {
    	//TO DO
    }
    
  2. Start a microphone testing session.

    let testAudioDeviceHelper = ZoomVideoSDK.shareInstance()?.getTestAudioDeviceHelper()
    let err = testAudioDeviceHelper?.startMicTest()
    
    ZoomVideoSDKTestAudioDeviceHelper* testAudioDeviceHelper = [[ZoomVideoSDK shareInstance] getTestAudioDeviceHelper];
    ZoomVideoSDKError err = [testAudioDeviceHelper startMicTest];
    
  3. After calling startMicTest, the microphone will start recording for 6 seconds. During this time, you'll receive the callback onMicSpeakerVolumeChanged with the microphone volume. When the recording stops, you'll receive the callback onTestMicStatusChanged with the status ZoomVideoSDKMic_CanPlay. Once you receive the status, you'll be able to start playing the microphone recording.

    let err = testAudioDeviceHelper?.playMicTest()
    
    ZoomVideoSDKError err = [testAudioDeviceHelper playMicTest];
    
  4. When the microphone recording is played, you'll receive the callback onTestMicStatusChanged with the status ZoomVideoSDKMic_CanTest. After receiving this status, call startMicTest again if needed.

  5. To finish the microphone testing session, call stopMicTest.

    let err = testAudioDeviceHelper?.stopMicTest()
    
    ZoomVideoSDKError err = [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.

    // Setup for speaker test - E.g. test.mp3
    let initParams = ZoomVideoSDKInitParams()
    let extendParams = ZoomVideoSDKExtendParams()
    let bundle = Bundle.main
    extendParams.speakerTestFilePath = bundle.path(forResource: "test", ofType: "mp3")
    
    // Setup for speaker test - E.g. test.mp3
    ZoomVideoSDKInitParams *initParams = [[ZoomVideoSDKInitParams alloc] init];
    ZoomVideoSDKExtendParams *extendParams = [[ZoomVideoSDKExtendParams alloc] init];
    NSString *lpath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"mp3"];
    extendParams.speakerTestFilePath = lpath;
    
  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.

    // Add the extendParams to ZoomVideoSDKInitParams params
    initParams.extendParam = extendParams
    // Get ZoomVideoSDKTestAudioDeviceHelper to test the speakers
    if let testAudioDeviceHelper = ZoomVideoSDK.shareInstance()?.getTestAudioDeviceHelper() {
        //...
    }
    
    // Add the extendParams to ZMVideoSDKInitParams initParams
    initParams.extendParam = extendParams;
    // Get ZMVideoSDKTestAudioDeviceHelper to test the speaker
    ZMVideoSDKTestAudioDeviceHelper *testAudioDeviceHelper = [[ZMVideoSDK shareInstance] getTestAudioDeviceHelper];
    
  4. Start the speaker test. You'll receive the callback onMicSpeakerVolumeChanged with the speaker volume if it's successful.

        //...
        // Start Speaker Test
        testAudioDeviceHelper.startSpeakerTest()
        //...
    
    ZMVideoSDKErrors err = [testAudioDeviceHelper startSpeakerTest:selectSpkDeviceID];
    
  5. Stop the speaker test.

        //...
        // Stop Speaker Test - This method only works when startSpeakerTest was called successfully
        testAudioDeviceHelper.stopSpeakerTest()
    }
    
    ZMVideoSDKErrors err = [testAudioDeviceHelper stopSpeakerTest];