1.0.1 • Published 6 months ago

use-media-device v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

useMediaDevice

How to use it?

function Camera() {
  const { takePhoto, videoRef } = useMediaDevice({ video: true, audio: false });
  const [img, setImg] = useState();

  return (
    <div>
      <video ref={videoRef}></video>
      <button onClick={() => setImg(takePhoto())}>Take Photo</button>
      <img src={img} alt="" />
    </div>
  );
}

useMediaDevice parameter;

parametertypedefaultdescription
autoStartbooleantruestart media permissions when component is loaded
audiobooleantruemicrophone access
videobooleantruewebcam access

useMediaDevice also exports media which is MediaStream instance it let's you do anything with it

Usage

Visit API Reference from here

Contributing

Pull requests are always welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT