Skip to content

通用事件

注意

通用事件为组件的加载状态事件,具体请参考下方说明

用法示例

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

回调示例

json
{
  "type": "onAttach",
  "data": {
    "message": "",
    "code": 0,
    "data": {
      "device": {
        "deviceName": "/dev/bus/usb/001/003",
        "productName": "RXGD-CAMERA",
        "serialNumber": "200901010001",
        "vendorId": 3034,
        "productId": 12337,
        "deviceId": 1003
      }
    }
  }
}
json
{
  "type": "onCameraClose",
  "data": {
    "message": "",
    "code": 0,
    "data": {
      "device": {
        "deviceName": "/dev/bus/usb/001/003",
        "productName": "RXGD-CAMERA",
        "serialNumber": "200901010001",
        "vendorId": 3034,
        "productId": 12337,
        "deviceId": 1003
      }
    }
  }
}
json
{
  "type": "onCameraOpen",
  "data": {
    "message": "",
    "code": 0,
    "data": {
      "device": {
        "deviceName": "/dev/bus/usb/001/003",
        "productName": "RXGD-CAMERA",
        "serialNumber": "200901010001",
        "vendorId": 3034,
        "productId": 12337,
        "deviceId": 1003
      }
    }
  }
}
json
{
  "type": "onCancel",
  "data": {
    "message": "",
    "code": 0,
    "data": {
      "device": {
        "deviceName": "/dev/bus/usb/001/003",
        "productName": "RXGD-CAMERA",
        "serialNumber": "200901010001",
        "vendorId": 3034,
        "productId": 12337,
        "deviceId": 1003
      }
    }
  }
}
json
{
  "type": "onDetach",
  "data": {
    "message": "",
    "code": 0,
    "data": {
      "device": {
        "deviceName": "/dev/bus/usb/001/003",
        "productName": "RXGD-CAMERA",
        "serialNumber": "200901010001",
        "vendorId": 3034,
        "productId": 12337,
        "deviceId": 1003
      }
    }
  }
}
json
{
  "type": "onDeviceClose",
  "data": {
    "message": "",
    "code": 0,
    "data": {
      "device": {
        "deviceName": "/dev/bus/usb/001/003",
        "productName": "RXGD-CAMERA",
        "serialNumber": "200901010001",
        "vendorId": 3034,
        "productId": 12337,
        "deviceId": 1003
      }
    }
  }
}
json
{
  "type": "onDeviceOpen",
  "data": {
    "message": "",
    "code": 0,
    "data": {
      "device": {
        "deviceName": "/dev/bus/usb/001/003",
        "productName": "RXGD-CAMERA",
        "serialNumber": "200901010001",
        "vendorId": 3034,
        "productId": 12337,
        "deviceId": 1003
      }
    }
  }
}
json
{
  "type": "onQuitFullScreen",
  "data": {
    "message": "",
    "code": 0,
    "data": {}
  }
}
json
{
  "message": "",
  "code": 0,
  "data": {
    "status": "start"
  }
}
{
  "message": "",
  "code": 0,
  "data": {
    "path": "/storage/emulated/0/Android/data/test.leven.uniplugin.com/video/1709286764483.mp4",
    "status": "finish"
  }
}

回调说明

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

回调事件类型说明

摄像头插入

类型名称

onAttach

回调说明

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

关闭摄像头

类型名称

onCameraClose

回调说明

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

打开摄像头

类型名称

onCameraOpen

回调说明

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

取消设备

类型名称

onCancel

回调说明

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

断开连接

类型名称

onDetach

回调说明

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

关闭设备

类型名称

onDeviceClose

回调说明

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

打开设备

类型名称

onDeviceOpen

回调说明

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

退出全屏

类型名称

onQuitFullScreen

回调说明

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

视频录制结果

类型名称

onRecordingResult

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
data.statusString录制状态
start:开始录像
finish:结束录像
data.pathString录像文件路径,结束录像后会返回
codeInteger返回类型,0.成功,其他:失败