Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera not closing on iOS #235

Open
rpaugh opened this issue May 16, 2023 · 4 comments
Open

Camera not closing on iOS #235

rpaugh opened this issue May 16, 2023 · 4 comments

Comments

@rpaugh
Copy link

rpaugh commented May 16, 2023

After launching the camera on iOS, the barcode is correctly scanned and processed in the background, the camera pauses letting you know this action took place, but the camera never closes. I have to manually close out of the camera to get back to my app that launched it. I am calling scanner.stop() during the setResult call:

` const scanner = new QrScanner(video, result => setResult(fileQrResult, result), {
onDecodeError: error => {
fileQrResult.textContent = error;
fileQrResult.style.color = 'inherit';
},
highlightScanRegion: true,
highlightCodeOutline: true
});
scanner.setCamera('user');

function setResult(label, result) {
    scanner.stop();
    try {

...
}`

Is there something else I need to do for the scanner to force close the camera after the scan?

@Mikiewitch
Copy link

Same thing happens on Android and Windows. Any luck with this issue?

@Mikiewitch
Copy link

Mikiewitch commented Aug 15, 2023

Seems like this could help:

                const mediaStream = videoElement.srcObject;
                if (mediaStream instanceof MediaStream) {
                    const tracks = mediaStream.getTracks();
                    tracks.forEach(track => {
                        track.stop();
                    });

                    videoElement.srcObject = null;
                }

@rpaugh
Copy link
Author

rpaugh commented Aug 17, 2023

By "videoElement" are you referring to the video html tag?

@Mikiewitch
Copy link

Yes, the one you are passing as parameter to QrScanner constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants