Skip to content

Commit

Permalink
Merge pull request #1470 from ecency/bugfix/camera-switching
Browse files Browse the repository at this point in the history
Camera switching: fixed camera switching even if camera web recorder is broken
  • Loading branch information
feruzm authored Sep 29, 2023
2 parents 324bdae + b8d78ce commit 7bbb44c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ import { useGetCameraList } from "./utils";
interface Props {
noPermission: boolean;
mediaRecorder?: MediaRecorder;
recordButtonShow?: boolean;
onCameraSelect: (camera: MediaDeviceInfo) => void;
}

export function VideoUploadRecorderActions({ noPermission, mediaRecorder, onCameraSelect }: Props) {
export function VideoUploadRecorderActions({
noPermission,
mediaRecorder,
onCameraSelect,
recordButtonShow
}: Props) {
const cameraList = useGetCameraList();

const [currentCameraIndex, setCurrentCameraIndex] = useState(0);
Expand Down Expand Up @@ -48,6 +54,9 @@ export function VideoUploadRecorderActions({ noPermission, mediaRecorder, onCame
{rectSvg}
</div>
) : (
<></>
)}
{!recordStarted && recordButtonShow ? (
<div
aria-disabled={noPermission}
className="record-btn"
Expand All @@ -58,6 +67,8 @@ export function VideoUploadRecorderActions({ noPermission, mediaRecorder, onCame
>
{circleSvg}
</div>
) : (
<></>
)}
</div>
<div />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,19 @@ export function VideoUploadRecorder({
<></>
)}

{!noPermission && !recordedVideoSrc ? (
<VideoUploadRecorderActions
noPermission={noPermission}
mediaRecorder={mediaRecorder}
onCameraSelect={(camera) => {
stream
?.getTracks()
.filter(({ kind }) => kind === "video")
.forEach((track) => track.stop());

setCurrentCamera(camera);
}}
/>
) : (
<></>
)}
<VideoUploadRecorderActions
noPermission={noPermission}
mediaRecorder={mediaRecorder}
recordButtonShow={!noPermission && !recordedVideoSrc}
onCameraSelect={(camera) => {
stream
?.getTracks()
.filter(({ kind }) => kind === "video")
.forEach((track) => track.stop());

setCurrentCamera(camera);
}}
/>

{noPermission ? (
<VideoUploadRecorderNoPermission />
Expand Down

0 comments on commit 7bbb44c

Please sign in to comment.