From 1dae6c5a362cc069627d0c51111800ba027454e8 Mon Sep 17 00:00:00 2001 From: Sandip Das Date: Thu, 30 May 2024 21:02:06 +0530 Subject: [PATCH 1/4] added mute preview --- src/react-webcam.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/react-webcam.tsx b/src/react-webcam.tsx index 5b054ca..3b3642f 100644 --- a/src/react-webcam.tsx +++ b/src/react-webcam.tsx @@ -61,6 +61,7 @@ export type WebcamProps = Omit, "ref"> & { mirrored: boolean; minScreenshotHeight?: number; minScreenshotWidth?: number; + mutePreview?: boolean; onUserMedia: (stream: MediaStream) => void; onUserMediaError: (error: string | DOMException) => void; screenshotFormat: "image/webp" | "image/png" | "image/jpeg"; @@ -391,6 +392,7 @@ export default class Webcam extends React.Component { screenshotQuality, minScreenshotWidth, minScreenshotHeight, + mutePreview = true, audioConstraints, videoConstraints, imageSmoothing, @@ -412,7 +414,7 @@ export default class Webcam extends React.Component { autoPlay disablePictureInPicture={disablePictureInPicture} src={state.src} - muted={!audio} + muted={mutePreview} playsInline ref={ref => { this.video = ref; From 5508e79fddcf9dc45a48807cd27eaf062c54f698 Mon Sep 17 00:00:00 2001 From: Sandip Das Date: Thu, 30 May 2024 21:04:35 +0530 Subject: [PATCH 2/4] added mutePreview doc --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9f7a01e..6256526 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ The props here are specific to this component but one can pass any prop to the u | mirrored | boolean | false | show camera preview and get the screenshot mirrored | | minScreenshotHeight | number | | min height of screenshot | | minScreenshotWidth | number | | min width of screenshot | +| mutePreview | boolean | | mute/unmute video preview | | onUserMedia | function | noop | callback for when component receives a media stream | | onUserMediaError | function | noop | callback for when component can't receive a media stream with MediaStreamError param | | screenshotFormat | string | 'image/webp' | format of screenshot | From 8a881876b22471868c2e8e4faae69aac15cc8d8a Mon Sep 17 00:00:00 2001 From: Sandip Das Date: Thu, 30 May 2024 21:08:28 +0530 Subject: [PATCH 3/4] modified test for vide when muted --- src/__tests__/react-webcam.test.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/__tests__/react-webcam.test.tsx b/src/__tests__/react-webcam.test.tsx index 0937a46..2293c73 100644 --- a/src/__tests__/react-webcam.test.tsx +++ b/src/__tests__/react-webcam.test.tsx @@ -33,7 +33,7 @@ it('renders correctly', () => { expect(tree.toJSON()).toMatchSnapshot(); }); -it('sets