I’m trying to use the optional sound settings in the BarcodeScanner class of ERPNext, as mentioned in the code comment:
// optional sound name to play when scan either fails or passes.
// see https://frappeframework.com/docs/v14/user/en/python-api/hooks#sounds
this.success_sound = opts.play_success_sound;
this.fail_sound = opts.play_fail_sound;
I would like to activate these sounds during barcode scanning (e.g. in Pick List or Stock Entry), so that:
a sound like "submit" is played on successful scans
a sound like "error" is played when the item is not found
However, most doctypes initialize BarcodeScanner internally, and I’m not sure how or where to pass these options (play_success_sound, play_fail_sound) during that process.
My question is:
How can I activate these sounds via Custom Script or config, without fully reinitializing the BarcodeScanner?
Is there a recommended way to inject these options globally or after scanner init?
…and that the methods play_success_sound() and play_fail_sound() are called inside process_scan().
But most doctypes (like Pick List) initialize the scanner internally, and there is no documented way to pass those options into the constructor from a Custom Script.