![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
A library that facilitates the integration of camera support into web applications.
The JSnapCam
is a JavaScript class that facilitates webcam interaction and streaming. It provides methods to access and manage video input devices, start and stop webcam streaming, take photos, and more.
The JSnapCam
simplifies webcam interactions in web applications. It allows you to:
git https://github.com/iguilhermeluis/JSnapCam.git
npm install jsnapcam
# or
yarn add jsnapcam
To use the JSnapCam
in your project, you can either include the source code directly in your JavaScript bundle or import the class from a module.
<script
type="text/javascript"
src="https://unpkg.com/jsnapcam/dist/jsnapcam.min.js"
></script>
or Import into javascript
import Webcam from "jsnapcam";
constructor(
webcamElement,
facingMode,
canvasElement,
snapSoundElement,
ratio,
activateAutofocusIfItExists,
rememberLastCameraChoice
);
Creates a new instance of the JSnapCam.
webcamElement
: The HTML video element that will display the webcam stream.canvasElement (optional)
: The HTML canvas element for capturing images. Default is null.snapSoundElement (optional)
: The HTML audio element to play a sound when taking a photo. Default is null.ratio (optional)
: The aspect ratio for capturing images. Default is 16:9.activateAutofocusIfItExists (optional)
: Enables continuous autofocus if supported. Default is true.rememberLastCameraChoice (optional)
: Enable saving the last camera choice to local storage. Default is true.facingMode
- Gets or sets the current facing mode of the camera (either "user" or "environment").
webcamList
- Gets the list of available video input devices (MediaDeviceInfo[]).
webcamCount
- Gets the number of available video input devices.
selectedDeviceId
- Gets or sets the ID of the selected video input device.
streamList
- Gets the list of camera streams (MediaStream[]).
start(startStream)
- Starts the webcam and begins streaming if specified.stream()
- Starts streaming the webcam to the video element.stop()
- Stops the webcam streaming and releases the media tracks.snap()
- Takes a photo from the webcam and returns the image as a base64 string.flip()
- Flips the camera's facing mode between "user" and "environment".getInfoVideoInputs()
- Gets information about available video input devices.Contributions to the JSnapCam are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.
Thanks goes to these wonderful people (emoji key):
Guilherme L. Faustino 💻 📖 ⚠️ |
The JSnapCam is licensed under the MIT License. Feel free to use it in your projects, both personal and commercial.
FAQs
A library that facilitates the integration of camera support into web applications.
We found that jsnapcam demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.