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

Add await to this.surface.play() #648

Merged
merged 1 commit into from
Jan 22, 2023
Merged

Add await to this.surface.play() #648

merged 1 commit into from
Jan 22, 2023

Conversation

pholawat-tle
Copy link
Contributor

When we call the start function of the Html5QrCode object, the promise was resolved before the video from the camera is ready/rendered, thus making it currently not possible to chain the promise of the start function with other operations like stop, pause, etc.

Also, the exceptions thrown inside .play() promise were not being handled

Before (Chaining with pause)

const qrCode = new Html5Qrcode('reader-id')

qrCode.start(
    { facingMode: 'environment' },
    { fps: 10 },
    () => {},
    () => {}
    ).then(
        () => qrCode.pause()
    );

Screen Shot 2565-12-12 at 19 19 25

After (Chaining with pause)

Screen Shot 2565-12-12 at 19 14 44

Before (Chaining with stop)

const qrCode = new Html5Qrcode('reader-id')

qrCode.start(
    { facingMode: 'environment' },
    { fps: 10 },
    () => {},
    () => {}
    ).then(
        () => qrCode.stop()
    );

Screen Shot 2565-12-12 at 19 22 15

After (Chaining with stop)

Screen Shot 2565-12-12 at 19 23 16

@mebjas
Copy link
Owner

mebjas commented Jan 22, 2023

Thanks for the fix, merging.

@mebjas mebjas self-requested a review January 22, 2023 06:00
@mebjas mebjas merged commit 4d384a0 into mebjas:master Jan 22, 2023
Timeswitch pushed a commit to thammit/html5-qrcode that referenced this pull request Feb 14, 2023
This reverts commit 128c0b4.

Revert "Bump decode-uri-component from 0.2.0 to 0.2.2 (mebjas#647)"

This reverts commit d28c09a.

Revert "add await to this.surface.play() (mebjas#648)"

This reverts commit 4d384a0.

Revert "Bump json5 from 1.0.1 to 1.0.2 (mebjas#667)"

This reverts commit 7f57cad.

Revert "Fixes/657 (mebjas#671)"

This reverts commit 4a9a039.
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

Successfully merging this pull request may close these issues.

2 participants