Skip to content

切换摄像头

注意

方法名

switchCamera

用法

js
function switchCamera() {
    if (deviceList.value == null || deviceList.value.length == 0) {
      uni.showToast({
        title: "请先获取摄像头列表",
        icon: "none"
      })
      return;
    }
    deviceIndex.value++;
    if (deviceIndex.value >= deviceList.value.length) {
      deviceIndex.value = 0;
    }
    const deviceName = deviceList.value[deviceIndex.value].getString("deviceName")
    const params : JSONObject = new JSONObject();
    params.put("deviceName", deviceName)
    refLevenUvc.value?.switchCamera(params)
  }

参数说明

参数名参数类型是否必填默认值参数描述
deviceNameString摄像头名称