Skip to content

cameraHandler.current?.stop(); not working #2

@TrickUK

Description

@TrickUK

Version: 1.1.0

Hi,

Many thanks for the nicely written component, it is perfect for my needs. I do however need the stop function to work, so that the camera is available for use by another component on the same page.

I am using your WebCamera component in a MUI Dialog, which when closed should stop() the camera. I have added the call in my handleClose() function and although the camera LED on my laptop flickers, the camera remains in use even after the dialog is closed and the LED stays on until I close my browser.

Looking at the other component I'm using, which works (https://github.com/yudielcurbelo/react-qr-scanner/blob/main/src/hooks/useCamera.ts), it looks like there are some differences in the stop code:

videoEl.src = '';
videoEl.srcObject = null;
videoEl.load();

for (const track of stream.getTracks()) {
	stream.removeTrack(track);
	track.stop();
}

I wonder if this might solve the issue in your component also? I would gladly try it, but not sure exactly how to setup the development environment for this.

Any help much appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions