Skip to content

Commit

Permalink
[email protected] 🌶️ README upd & SSR fix
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-mir committed Feb 21, 2024
2 parents fba14db + b86268c commit 2842185
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ The component also supports many properties for more specific work:
| mainCamera | boolean | false | should use a main camera (requires Navigator.mediaDevices.enumerateDevices) |
| frontCamera | boolean | false | should use a front camera (MediaTrackConstraints['facingFront'] === 'user') |
| applyConstraints | boolean | false | should new constraints be applied to the media stream |
| cameraResolutionType | string | | video track resolution size - 'UHD' | 'QHD' | 'FHD' | 'HD' |
| cameraResolutionMode | string | 'ideal' | video track resolution mode - 'min' | 'max' | 'ideal' | 'exact' |
| cameraResolutionType | string | | video track resolution size - `('UHD' \| 'QHD' \| 'FHD' \| 'HD')` |
| cameraResolutionMode | string | 'ideal' | video track resolution mode - `('min' \| 'max' \| 'ideal' \| 'exact')` |
| audioConstraints | object | | audio track constraints - MediaStreamConstraints['audio'] |
| videoConstraints | object | | video track constraints - MediaStreamConstraints['video'] |
| requestTimeLimit | number | | limiting the media stream request by time |
Expand Down
9 changes: 5 additions & 4 deletions src/utils/helpers/stream/getUserMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { hasGetUserMedia } from './hasGetUserMedia';
// ✅ important
// Implementations for each browser need to be supported
export const getUserMediaFunction =
navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia;
typeof window !== 'undefined' &&
(navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);

// ✅ important
// Polyfill to support legacy web-api
Expand Down
4 changes: 3 additions & 1 deletion src/utils/helpers/stream/stopMediaStream.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const stopMediaStream = (stream: MediaStreamTrack | MediaStream) => {
export const stopMediaStream = (stream?: MediaStreamTrack | MediaStream) => {
if (!stream) return;

if (stream instanceof MediaStreamTrack) {
stream.stop();
return;
Expand Down
1 change: 0 additions & 1 deletion src/utils/hooks/useMediaStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export const useMediaStream = ({

return () => {
handlerRef.current.stop?.(runningStream);
if (!runningStream) return;
stopMediaStream(runningStream);
};
}, [
Expand Down

0 comments on commit 2842185

Please sign in to comment.