
# getMediaDevices(获取设备列表)
#### 接口描述
获取本地设备列表，如麦克风和扬声器。
#### 注意事项
需要账号注册成功后才能调用该接口。
#### 方法定义
```
OpenEyeCall.prototype.getMediaDevices = function(type, callbacks)
```
#### 参数描述
表1参数说明 
| 参数名       | 类型                                                             | 可选/必选 | 描述                  |
|:---|:---|:---|:---|
| type      | Number                                                         | 必选    | 设备类型。0表示麦克风，1表示扬声器。 |
| callbacks | [Callback] | 可选    | 回调方法。               |
   
 表2Callback 
| 参数名      | 类型       | 可选/必选 | 描述                                                                 |
|:---|:---|:---|:---|
| response | function | 必选    | 回调方法的入参请参考[表3] |
   
 表3回调方法的入参 
| 参数名         | 类型                                                      | 描述                 |
|:---|:---|:---|
| description | String                                                  | 当前请求描述。            |
| result      | Number                                                  | 查询结果。0表示成功，其他表示失败。 |
| rsp         | Number                                                  | 内部消息编号。            |
| param       | [Param] | 设备信息。              |
   
 表4Param 
| 参数名        | 类型                                                         | 描述    |
|:---|:---|:---|
| array      | [设备]的数组 | 设备列表。 |
| device_num | Number                                                     | 设备数。  |
   
 表5设备 
| 参数名           | 类型     | 描述    |
|:---|:---|:---|
| camera_orient | Number | 预留字段  |
| index         | Number | 设备序号。 |
| name          | String | 设备名称。 |
   
![](https://support.huaweicloud.com/devg-openeye-cec/public_sys-resources/note_3.0-zh-cn.png)
回调方法的入参示例：
```
{
   "description" : "tsdk_get_devices",
   "param" : {
      "deviceInfo" : [
         {
                "cameraOrient":0,
"deviceId":0,
"deviceName":
"default: 扬声器 (Huawei HDP Audio Driver)",
"index":0
         },
         {
                "cameraOrient":0,
"deviceId":0,
"deviceName":"扬声器 (Huawei HDP Audio Driver)",
"index":1
         }
      ],
      "deviceType":1，
      "num" : 2
   },
   "result" : 0,
   "rsp" : 67550
}
```
#### 使用示例
```
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");
    }
}
```
