Updated on 2023-10-12 GMT+08:00

getMediaDevices (Obtaining the Device List)

Interface Description

This interface is invoked to obtain the local device list, such as the microphone and speaker.

Notes

This interface can be invoked only after an account is successfully registered.

Method Definition

OpenEyeCall.prototype.getMediaDevices = function(type, callbacks)

Parameter Description

Table 1 Parameter description

Parameter

Type

Mandatory/Optional

Description

type

Number

Mandatory

Device type. The value 0 indicates a microphone, and the value 1 indicates a speaker.

callbacks

Callback

Optional

Callback method.

Table 2 Callback

Parameter

Type

Mandatory/Optional

Description

response

function

Mandatory

For details about the input parameters of the callback method, see Table 3.

Table 3 Input parameters of the callback method

Parameter

Type

Description

description

String

Description of the current request.

result

Number

Query result. The value 0 indicates success and other values indicate failure.

rsp

Number

Internal message ID.

param

Param

Device information.

Table 4 Param

Parameter

Type

Description

array

Device (Table 5) array

Device list.

device_num

Number

Number of devices.

Table 5 Devices

Parameter

Type

Description

camera_orient

Number

Reserved field.

index

Number

Serial number of a device.

name

String

Device name.

The following is an example of input parameters of the callback method:
{
   "description" : "tsdk_get_devices",
   "param" : {
      "deviceInfo" : [
         {
                "cameraOrient":0,
		"deviceId":0,
		"deviceName":
		"default: Speaker (Huawei HDP Audio Driver)",
		"index":0

         },
         {
                "cameraOrient":0,
		"deviceId":0,
		"deviceName":"Speaker (Huawei HDP Audio Driver)"
		"index":1
         }
      ],
      "deviceType": 1,
      "num" : 2
   },
   "result" : 0,
   "rsp" : 67550
}

Examples

function getMediaDevices() {
    global_openEye_SDK.openEyeCall.getMediaDevices(1, {
        response: getMediaDevicesResponse
    });
}

function getMediaDevicesResponse(data) {
    console.info(data);
    if (data.result == 0) {
        console.info("GetMediaDevices success");
    } else {
        console.error("GetMediaDevices failed");
    }
}