New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@onlymisaky/web-camera

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onlymisaky/web-camera

web camera

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

Camera

网页版相机

TODO

  • 打包
  • 在线用例
  • 完整的 README

用法

  • 需要 https 支持,或者 file 协议
  • 同时需要用户同意打开摄像头
const camera = new Camera(document.querySelector('video'));

(async () => {
  try {
    const cameraList = await camera.getCameraList();
    if (cameraList) {
      await camera.open({ video: { deviceId: cameraList[0].deviceId } });
      const canvas = await camera.md2Canvas();
      document.querySelector('img').src = canvas.toDataURL('Image/jpeg', 1)
    }
  } catch (err) {
    throw err
  }
})();

API

函数参数返回值说明
getCameraList---Promise<MediaDeviceInfo[]>获取摄像头列表
openconstraints:MediaStreamConstraints, force: booleanMediaStream打开相机, force 默认为 false, 传 true 表示重新打开
close--void关闭相机
md2Canvas--HTMLCanvasElement截取图片
destroy--void销毁

Keywords

web camera

FAQs

Package last updated on 04 Mar 2020

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