I’m trying to extend the POS so that when the user scans a barcode if the barcode does not correspond to a product, the POS with play an audio file to alert the user that the barcode they just scanned is invalid.
I have added a Sounds folder under the Resources folder in my POS project in the CommerceSDK. When we build the CommerceSDK locally it is replicating this audio resource folder to C:\Program Files\Microsoft Dynamics 365\10.0\Store Commerce\Extensions\BHS.Commerce\POS\Resources\Sounds\alarm.mp3.
At runtime audio.src is set to local.storecommerce.dynamics.com/.../alarm.mp3, and it doesn’t give me an error, but the audio doesn’t play. I have confirmed the SCA's ability to play audio with this code by replacing the local call with a URL to an MP3 (https://www.soundjay.com/misc/sounds/bell-ringing-01c.mp3) which is played.
However, we need to support this functionality in offline mode, so we are hoping to have it available as a local resource. I have tried to make a reference to the audio on the POS project manifest file in the resources section, but it never compiles.
I have also tried creating an audio.d.ts file under Pos/Libraries that contained the following code:
declare module "*.mp3";
declare module "*.wav";
Then in my RequestHandler I added the import statement:
import note from '../../Resources/Sounds/alarm.mp3';
And then I created the Audio object with this code:
let audio = new Audio(note);
My extension failed to load on the SCA when I did this though.
Ultimately, I've confirmed that the code playing the audio is working so the issue has to do with the location of the audio file in my resources and/or how the CommerceSDK is making that resource available at the SCA. Any advice on how to link the resource up with my codebase would be greatly appreciated.