download
raw
960 Bytes
import _extends from '@babel/runtime/helpers/esm/extends';
import * as React from 'react';
import { forwardRef, useEffect } from 'react';
import { suspend, clear } from 'suspend-react';
import { VideoTexture } from '../core/VideoTexture.js';
/**
* Create a video texture from [`getUserMedia`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia)
*/
const WebcamVideoTexture = /* @__PURE__ */forwardRef(({
constraints = {
audio: false,
video: {
facingMode: 'user'
}
},
...props
}, fref) => {
const mediaStream = suspend(() => navigator.mediaDevices.getUserMedia(constraints), []);
useEffect(() => {
return () => {
mediaStream == null || mediaStream.getTracks().forEach(track => track.stop());
clear([]);
};
}, [mediaStream]);
return /*#__PURE__*/React.createElement(VideoTexture, _extends({
ref: fref
}, props, {
src: mediaStream
}));
});
export { WebcamVideoTexture };

Xet Storage Details

Size:
960 Bytes
·
Xet hash:
300adb7d30b56a1e72638edd5a10a883ad97340abefc6ca44064f00027084932

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.