You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

camera-util

Package Overview
Dependencies
Maintainers
0
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

camera-util

```bash npm install camera-util ```

1.0.21
latest
Source
npmnpm
Version published
Weekly downloads
1
-80%
Maintainers
0
Weekly downloads
 
Created
Source

Camera-util

导入插件

npm install camera-util

使用

1. 进入考试页面时初始化相机

useCamera.createCamera({
context: video dom,
constraints: {
    audio: false,// 是否开启音频
    video: {
    height: { ideal: 1080 },// 录制高度
    width: { ideal: 1920 },// 录制宽度
    frameRate: { ideal: 30 }// 帧率
    }
},
uploadConfig: {
    uploadModel: 'local',//本地存储还是云端上传
    uploadType: 'image',//录制模式还是图片模式
},
config: {//可选项,不设置则按默认值设置
    type: 'image/jpeg',//文件格式
    quality: 1,//图片的压缩因子
    width: 1080,//图片宽度
    height: 1920,//图片高度
}
})
参数说明类型是否必填
contextvideo的dom元素HTMLVideoElement必填
constraints摄像头参数IMediaStreamConstraints必填
uploadConfig上传参数IUploadConfig必填
config录制参数,type参数根据uploadType选择正确的文件格式ICameraMideaConfig选填

2. 答题开始时开启录制

const cb = await useCamera.startCatch() 
返回值说明
Promise结束录制时传入这个function

3. 答题过程中的操作调用

useCamera.upload(ossClient,
    {
        backQuestion: Boolean,
        currentIdex: Number,
        formId,
        userId,
        preDir
    })
参数说明类型是否必填
ossClient上传到云端的oss实例OSS必填
config上传参数(preDir是上传路径前缀)IUploadConfig必填

4. 结束答题时结束录制

useCamera.stopCatch(stopFn,{
    backQuestion: Boolean,
    currentIdex: Number,
    formId,
    userId,
    preDir
    })
参数说明类型是否必填
stopFn传入步骤2返回的函数Function必填
config上传参数(preDir是上传路径前缀)IUploadConfig必填

5. 离开答题页面时释放资源

useCamera.stopCamera()

FAQs

Package last updated on 12 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts