Skip to content

方法事件

注意

方法事件为组件方法调用后异步回调事件

用法示例

js
function onEventMethod(e : JSONObject) {
  console.log("onEvent:" + e.toJSONString())
}
js
//事件
onEventMethod(e) {
  console.log(e.detail)
}

回调示例

json
{
  "type": "onClose",
  "data": {
      "message": "",
      "code": 0,
      "data": {}
  }
}
json
{
  "type": "onOpen",
  "data": {
      "message": "",
      "code": 0,
      "data": {}
  }
}
json
{
  "type": "onStopPreview",
  "data": {
      "message": "",
      "code": 0,
      "data": {}
  }
}
json
{
  "type": "onStartPreview",
  "data": {
      "message": "",
      "code": 0,
      "data": {}
  }
}
json
{
  "type": "onStartRecording",
  "data": {
      "message": "",
      "code": 0,
      "data": {}
  }
}
json
{
  "type": "onStopRecording",
  "data": {
      "message": "",
      "code": 0,
      "data": {}
  }
}
json
{
  "type": "onTakePicture",
  "data": {
    "message": "",
    "code": 0,
    "data": {
      "base64": "",
      "path": "/storage/emulated/0/Pictures/LevenUvcCamera/1765987541706.jpg"
    }
  }
}
json
{
  "type": "onGetDeviceList",
  "data": {
    "message": "",
    "code": 0,
    "data": {
      "deviceList": [
        {
          "productId": 12337,
          "productName": "RXGD-CAMERA",
          "serialNumber": "200901010001",
          "deviceName": "/dev/bus/usb/003/003",
          "vendorId": 3034,
          "deviceId": 3003
        }
      ]
    }
  }
}
json
{
  "type": "onSwitchCamera",
  "data": {
    "message": "",
    "code": 0,
    "data": {}
  }
}
json
{
  "type": "onFullScreen",
  "data": {
    "message": "",
    "code": 0,
    "data": {}
  }
}
json
{
  "type": "onGetBrightnessPercent",
  "data": {
    "message": "",
    "code": 0,
    "data": {
      "percent": 50
    }
  }
}
json
{
  "type": "onSetBrightnessPercent",
  "data": {
    "message": "",
    "code": 0,
    "data": {}
  }
}
json
{
  "type": "onGetContrastPercent",
  "data": {
    "message": "",
    "code": 0,
    "data": {
      "percent": 50
    }
  }
}
json
{
  "type": "onSetContrastPercent",
  "data": {
    "message": "",
    "code": 0,
    "data": {}
  }
}
json
{
  "type": "onSetMirror",
  "data": {
    "message": "",
    "code": 0,
    "data": {}
  }
}
json
{
  "type": "onGetPreviewSize",
  "data": {
    "message": "",
    "code": 0,
    "data": {
      "type": 7,
      "fps": 30,
      "height": 600,
      "width": 800,
      "fpsList": [
        30
      ]
    }
  }
}
json
{
  "type": "onGetSupportedSizeList",
  "data": {
    "message": "",
    "code": 0,
    "data": {
      "list": [
        {
          "type": 7,
          "fps": 30,
          "height": 720,
          "width": 1280,
          "fpsList": [
            30
          ]
        },
        {
          "type": 7,
          "fps": 30,
          "height": 120,
          "width": 160,
          "fpsList": [
            30
          ]
        },
        {
          "type": 7,
          "fps": 30,
          "height": 144,
          "width": 176,
          "fpsList": [
            30
          ]
        },
        {
          "type": 7,
          "fps": 30,
          "height": 240,
          "width": 320,
          "fpsList": [
            30
          ]
        },
        {
          "type": 7,
          "fps": 30,
          "height": 288,
          "width": 352,
          "fpsList": [
            30
          ]
        },
        {
          "type": 7,
          "fps": 30,
          "height": 480,
          "width": 848,
          "fpsList": [
            30
          ]
        },
        {
          "type": 7,
          "fps": 30,
          "height": 600,
          "width": 800,
          "fpsList": [
            30
          ]
        },
        {
          "type": 7,
          "fps": 30,
          "height": 540,
          "width": 960,
          "fpsList": [
            30
          ]
        },
        {
          "type": 7,
          "fps": 30,
          "height": 720,
          "width": 1280,
          "fpsList": [
            30
          ]
        },
        {
          "type": 7,
          "fps": 30,
          "height": 480,
          "width": 640,
          "fpsList": [
            30
          ]
        }
      ]
    }
  }
}
json
{
  "type": "onSetButtonCallback",
  "data": {
    "message": "",
    "code": 0,
    "data": {
      "type": "onButton",
      "button": 1,
      "status": 1
    }
  }
}

回调说明

参数名参数类型参数描述
typeString事件类型,请参考下方说明
dataObject事件数据
data.codeInteger事件结果类型,0.成功,其他:失败
data.dataInteger事件结果数据
data.messageString事件结果消息

回调事件类型说明

关闭摄像头

类型名称

onClose

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

打开摄像头

类型名称

onOpen

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

关闭预览

类型名称

onStopPreview

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

开启预览

类型名称

onStartPreview

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

开始录像

类型名称

onStartRecording

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

结束录像

类型名称

onStopRecording

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

拍照

类型名称

onTakePicture

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
data.pathString拍照保存路径
data.base64String拍照的base64数据
codeInteger返回类型,0.成功,其他:失败

获取摄像头列表

类型名称

onGetDeviceList

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
data.deviceListArray[Object]摄像头数据集合
data.deviceList.productIdInteger产品id
data.deviceList.productNameString产品名称
data.deviceList.serialNumberString串口号
data.deviceList.deviceNameString设备名称
data.deviceList.vendorIdInteger厂家id
data.deviceList.deviceIdInteger设备id
codeInteger返回类型,0.成功,其他:失败

切换摄像头

类型名称

onSwitchCamera

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

全屏

类型名称

onFullScreen

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

获取摄像头亮度百分比

类型名称

onGetBrightnessPercent

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
data.percentInteger亮度,范围:[0,100]
codeInteger返回类型,0.成功,其他:失败

设置摄像头亮度百分比

类型名称

onSetBrightnessPercent

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

获取摄像头的对比度百分比

类型名称

onGetContrastPercent

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
data.percentInteger亮度,范围:[0,100]
codeInteger返回类型,0.成功,其他:失败

设置摄像头对比度百分比

类型名称

onSetContrastPercent

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

设置镜像

类型名称

onSetMirror

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

获取预览分辨率

类型名称

onGetPreviewSize

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
data.typeInteger类型
data.fpsInteger帧率
data.heightInteger高度
data.widthInteger宽度
data.fpsListArray[Integer]帧率列表
codeInteger返回类型,0.成功,其他:失败

获取支持的分辨率

类型名称

onGetSupportedSizeList

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
data.listArray[Object]列表
data.list.typeInteger类型
data.list.fpsInteger帧率
data.heightInteger高度
data.list.widthInteger宽度
data.list.fpsListArray[Integer]帧率列表
codeInteger返回类型,0.成功,其他:失败

监听按钮

类型名称

onSetButtonCallback

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
data.typeString类型
onSetCallback:监听成功
onButton:按钮被点击
data.buttonInteger按钮标识
data.statusInteger状态
codeInteger返回类型,0.成功,其他:失败