npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cloudparker/easy-camera-svelte

v1.0.3

Published

Introducing a user-friendly library for camera features in Svelte! This library provides a hassle-free way to capture both images and videos. With its intuitive controls such as start, stop, play, pause, captureImage, startVideoRecording, stopVideoRecordi

Downloads

71

Readme

easy-camera-svelte

Introducing a user-friendly library for camera features in Svelte! This library provides a hassle-free way to capture both images and videos. With its intuitive controls such as start, stop, play, pause, captureImage, startVideoRecording, stopVideoRecording, autoOpen camera, mirrorDisplay, you can effortlessly customize your camera settings. The best part? This library does not require any additional dependencies.

Screenshot

Demo

Live demo

Install

npm install @cloudparker/easy-camera-svelte --save-dev

Sample

<script lang="ts">
	import EasyCamera from '$lib';
	let width = 600;
	let camera: EasyCamera;
	let mirrorDisplay = true;

	const handleImage = async () => {
		let imageData = await camera.captureImage();
		console.log(imageData);
	};

	const handleVideo = async () => {
		let blob = await camera.startVideoRecording();
		if (blob) {
			const url = URL.createObjectURL(blob);
			const a = document.createElement('a');
			a.href = url;
			a.download = 'video.mp4';
			document.body.appendChild(a);
			a.click();
		}
	};
</script>

<div>
	<EasyCamera bind:width style="border-radius:5px;" bind:this={camera} autoOpen bind:mirrorDisplay />
</div>

<button class="" type="button" on:click={() => camera.open()}>Start Camera</button>
<button class="" type="button" on:click={() => camera.close()}>Stop Camera</button>
<button class="" type="button" on:click={() => camera.pause()}>Pause</button>
<button class="" type="button" on:click={() => camera.resume()}>Resume</button>
<button class="" type="button" on:click={() => (mirrorDisplay = !mirrorDisplay)}>
	{mirrorDisplay ? 'Disbale' : 'Enable'} Mirror Display
</button>
<button class="" type="button" on:click={handleImage}>Capture Image</button>
<button class="" type="button" on:click={handleVideo}>Start Video recording</button>
<button class="" type="button" on:click={()=> camera.stopVideoRecording()}>Stop Video recording</button>

Props

width: number

Default: 340

Set width of the camera view, it automatically adjust the height of camra view based on the camera aspect ratio.

style: string

Style of the video view or camra view

mirrorDisplay: boolean

Default: true

Enable or Disable mirror display of the video

useFrontCamra: boolean

Default: true

Use front camera while lunching the camera view

useAudio: boolean

Default : true

User audio in video recording.

needFrames: boolean

Default : false

Incase you need all video frame data in the form of ImageData enable this option. The frame data will be publish on:frame event.

Events

on:init

Trigger when camra init, return all camera devide infos array.

on:video

Trigger when video recording stop, it return a video Blob data.

on:startVideoRecording

Trigger whhen video recording start

on:stopVideoRecording

Trigger when video Recording Stopped.

on:image

Triggered when image captured done, retrun with ImageData object or base64 image data, based on user request.

on:open

Trigger when camera oppend.

on:close

Trigger when camra closed/stopped.

on:pause

Trigger when camera paused.

on:resume

Trigger when camera resumed.

on:frame

Trigger everytime a frame rendered, it will call very frequently with ImageData object. Use the frame data for your external use.

Methods

open(): void

Open camera.

close(): void

Close camera.

pause(): void

Pause camera.

resume(): void

Resume camra.

startVideoRecording(): Promise

Start video recording and return video data Blob format.

stopVideoRecording(): video

Stop video recording

captureImage(isImageData?: boolean): Promise<ImageData | string | null>

Capture Image using camera. Pass isImageData when required ImageData instead of base64.

isRecording(): boolean

Check is recording .

switchCamera(deviceId?: string): void

Request to switch camera.

getCamraDevices(): Promise<MediaDeviceInfo[]>

Get all camera devices array