It will be nice if we may produce a beep or a sound effect when a code is read.
Browsers now do not accept a JavaScript call to play an audio unless the call is made within the context of an event caused by a user action (e.g. clicking a button). I have attempted another JavaScript library to read QR codes which generates an event when a code is detected. A JavaScript call to play an audio in the context of this event is accepted by the browsers as a legit call and the sound is played.
I have not been able to find something similar in ZXing JS library. Can we play an audio when decodeFromInputVideoDevice() returns results? Or perhaps this is a feature enhancement request.
It's a legit feature request, hehe. I have to figure out how to handle events like that library you're talking about, in fact, some events inside the code reader would be very awesome for a bunch of reasons. Also, I was thinking about adding some vibration effect (optional of course) when decoding happens and I'm wondering now if it would required a call inside an event callback too.
Stale issue message
const beepSound: HTMLAudioElement = new Audio('data:audio/wav;base64,//YOUR_BASE_64_AUDIO_HERE')
...
onScanSuccess(value): void {
beepSound.play()
}
this works fines on all the browsers that I tested (desktop and mobile/android)
It would be essentially good if this feature could be imported as the user (developer) wants to enable beeping.
Stale issue message
ping @odahcam
Most helpful comment
this works fines on all the browsers that I tested (desktop and mobile/android)