Ohos

更新时间:
复制 MD 格式

The RTC software development kit (SDK) provides features for device detection and management. You can check if your hardware devices are working correctly before you join a channel. This topic describes how to detect and manage devices.

Feature description

The RTC SDK provides methods for device detection and management. For example, the SDK lets you query device information, check if the camera is working, test audio recording and playback, set the camera orientation, or switch audio devices such as microphones and speakers.

Methods

The following are common methods for device detection and management. For more information, see the DingRtcEngine API.

  • switchCamera: Switches between the front and rear cameras. The front camera is used by default.

    switchCamera(): number

    Return value

    A value of 0 indicates that the method call is successful. Other values indicate that the method call failed.

  • setCameraZoom: Sets the camera zoom factor.

    setCameraZoom(zoom: number): number;

    Parameters

    Parameter

    Type

    Description

    zoom

    number

    The zoom level. The default value is 1.0.

    Return value

    A value of 0 indicates that the method call is successful. Other values indicate that the method call failed.

  • setCameraFlash: Turns the camera flash on or off.

    setCameraFlash(enable: boolean): number;

    Parameters

    Parameter

    Type

    Description

    enable

    boolean

    Specifies whether to turn on the camera flash. Valid values:

    • true: The feature is enabled.

    • false (default): The service is shut down.

    Return value

    A value of 0 indicates that the method call is successful. Other values indicate that the method call failed.

  • enableSpeakerphone: Switches the audio output between the earpiece and the speaker.

    enableSpeakerphone(enable: boolean): number;

    Parameters

    Parameter

    Type

    Description

    enable

    boolean

    Specifies whether to use the earpiece or the speaker for audio output. Valid values:

    • true (default): Speaker mode.

    • false: Earpiece mode.

    Return value

    A value of 0 indicates that the method call is successful. Other values indicate that the method call failed.