Appearance
切换摄像头
注意
该方法回调为异步事件,请参考方法事件
方法名
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;
}
let deviceName = deviceList.value[deviceIndex.value].getString("deviceName")
let options : UTSJSONObject = {
//参数
"deviceName": deviceName
};
let params : JSONObject = JSONObject.parse(JSON.stringify(options)) as JSONObject
refLevenUvc.value?.switchCamera(params)
}js
//切换摄像头
switchCamera() {
if (this.$refs.refLevenUvcCamera) {
if (this.deviceList.length == 0) {
this.showToast("请先获取摄像头列表")
return;
}
if (this.deviceIndex >= this.deviceList.length) {
this.deviceIndex = 0;
} else {
this.deviceIndex++;
}
this.$refs.refLevenUvcCamera.switchCamera({
//摄像头名称
deviceName: this.deviceList[this.deviceIndex].deviceName
})
}
}参数说明
| 参数名 | 参数类型 | 是否必填 | 默认值 | 参数描述 |
|---|---|---|---|---|
| deviceName | String | 是 | 无 | 摄像头名称 |
