tencent cloud



Last updated: 2022-06-22 15:13:27


    Given that it is difficult for users to detect device problems during a call, we recommend that you test devices such as cameras and mics before a video call.

    Supported Platforms

    iOS Android macOS Windows Electron Web
    × × ✓ (Web)

    Testing Camera

    You can use the startCameraDeviceTestInView API of TRTCCloud to test a camera and can use the setCurrentCameraDevice API to switch cameras during testing.

    // Open the camera testing page, on which you can preview camera images and switch cameras.
    - (IBAction)startCameraTest:(id)sender {
    // Start camera testing. `cameraPreview` is `NSView` on macOS or `UIView` on iOS.
    [self.trtcCloud startCameraDeviceTestInView:self.cameraPreview];

    // Close the camera testing page.
    - (void)windowWillClose:(NSNotification *)notification{
    // Stop camera testing.
    [self.trtcCloud stopCameraDeviceTest];

    Testing Mic

    You can use the startMicDeviceTest API of TRTCCloud to measure mic volume in real time. The result is returned via a callback.

    // Sample code for mic testing
    -(IBAction)micTest:(id)sender {
    NSButton *btn = (NSButton *)sender;
    if (btn.state == 1) {
    // Start mic testing.
    __weak __typeof(self) wself = self;
    [self.trtcCloud startMicDeviceTest:500 testEcho:^(NSInteger volume) {
    dispatch_async(dispatch_get_main_queue(), ^{
    // Refresh the mic volume bar.
    [wself _updateInputVolume:volume];
    btn.title = @"Stop test";
    // Stop mic testing.
    [self.trtcCloud stopMicDeviceTest];
    [self _updateInputVolume:0];
    btn.title = @"Start test";

    Testing Speaker

    You can use the startSpeakerDeviceTest API of TRTCCloud to test whether a speaker works properly by playing a default MP3 file.

    // Sample code for speaker testing
    // Take an NSButton for example. In `xib`, set the title of the button in the on and off state to "Stop Test" and "Start Test".
    - (IBAction)speakerTest:(NSButton *)btn {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"test-32000-mono" ofType:@"mp3"];
    if (btn.state == NSControlStateValueOn) {
    // Click "Start Test".
    __weak __typeof(self) wself = self;
    [self.trtcEngine startSpeakerDeviceTest:path onVolumeChanged:^(NSInteger volume, BOOL playFinished) {
    // The subsequent steps involve the UI and need to be executed in the main queue.
    dispatch_async(dispatch_get_main_queue(), ^{
    // `_updateOutputVolume` means updating the speaker volume indicator on the UI.
    [wself _updateOutputVolume:volume];
    if (playFinished) {
    // Set the button status to "Start Test" after playback is completed.
    sender.state = NSControlStateValueOff;
    } else {
    // Click "Stop Test".
    [self.trtcEngine stopSpeakerDeviceTest];
    [self _updateOutputVolume:0];

    // Update the speaker volume indicator.
    - (void)_updateOutputVolume:(NSInteger)volume {
    // `speakerVolumeMeter` is `NSLevelIndicator`.
    self.speakerVolumeMeter.doubleValue = volume / 255.0 * 10;
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support