# 视频管理

# 视频设备管理

# 获取摄像头列表

视频采集设置前,可以通过 getAllCameras (opens new window) 方法获取摄像头列表、当前摄像头以及默认摄像头,具体如下:

/**
 * 获取摄像头列表
 *
 * @return 摄像头列表
 */
const cameralist: carmeraItem[] = await this.JCEngine.getAllCameras();
interface cameraItem {
  cameraId: string;
  cameraName: string;
  cameraType: 0;
  // CAMERA_NONE = 0;未获取到摄像头
  // CAMERA_FRONT = 1; 前置摄像头
  // CAMERA_BACK = 2;后置摄像头
  // CAMERA_UNKNOWN = 3;未知摄像头
  // CAMERA_EXTERAL = 4; 外部摄像头
}

# 获取默认摄像头

可以通过调用getCamera获取当前使用的摄像头,具体方法如下:

/**
 * 当前默认的摄像头
 *
 * @return 当前摄像头
 */

const carmera = await this.JCEngine.getCamera();

# 切换摄像头

你可以通过调用switchCamera (opens new window)来切换当前使用的相机。

/**
 * 切换摄像头
 * @param camera 摄像头
 * @return 成功返回 true,失败返回 false
 */
this.JCEngine.switchCamera(camera:cameraItem);

示例代码

const cameraArr = this.JCEngine.getAllCameras();
if (cameraArr.length > 1) {
  this.JCEngine.switchCamera(cameraArr[1]);
}

# 设置摄像头采集属性

您可以通过调用setCameraProperty (opens new window)来设置自定义摄像头采集参数实现不同的视频分辨率,如采集的高度、宽度和帧速率。

摄像头采集属性设置接口如下:

/**
 * 设置摄像头采集属性
 * @param width     采集宽度,默认640
 * @param height    采集高度,默认360
 * @param frameRate 采集帧速率,默认30
 */
this.JCEngine.setCameraProperty(int width, int height, int frameRate);

示例代码

// 设置摄像头采集属性
this.JCEngine.setCameraProperty(640, 360, 30);

# 设置摄像头变焦倍数

您可以通过调用setCameraZoom (opens new window)来设置摄像头变焦倍数。


this.JCEngine.setCameraZoom(zoom:number);

示例代码

// 设置摄像头变焦倍数
this.JCEngine.setCameraZoom(30);

# 设置是否打开闪光灯

在开启闪光灯前请先调用isCameraTorchSupported (opens new window)判断一下当前的设备是否支持开启闪光灯,然后调用setCameraTorchOn (opens new window)开启闪光灯。


this.JCEngine.setCameraTorchOn(enable:boolean);

示例代码

//判断是否支持闪光灯
if (this.JCEngine.isCameraTorchSupported()) {
  //可以开启闪光灯
  this.JCEngine.setCameraZoom(30);
} else {
  //不可以开启闪光灯
}

# 设置曝光度

您可以通过调用setCameraExposureLevel (opens new window)来设置曝光度。


 this.JCEngine.setCameraExposureLevel(level:number);

示例代码

// 设置曝光度
this.JCEngine.setCameraExposureLevel(2);

# 视频高级功能

# 本地恢复/暂停渲染

this.$refs.JCVideoCanvas.callMethod({method: 'startLocalVideoDevice',args: {
     renderType:number ,
     play:boolean
  } ,()=>{}}

# 冻结渲染

this.$refs.JCVideoCanvas.callMethod(
  {
    method: "freezeRenderEffect",
    args: {
      enable: boolean,
    },
  },
  () => {}
);

# 单次截图

this.$refs.JCVideoCanvas.callMethod({
    method: 'takeOnceSnapshot',
    args: {
        width:number,
        height:number,
        filePath:string
    }
}, () => {})

# 摄像头聚焦


this.$refs.JCVideoCanvas.callMethod({
    method: 'setCameraFocus',
    args: {
        width:number,
        height:number,
        filePath:string
    }
}, () => {})

最后更新时间: 2023/11/23 15:08:55