LP#1815968 - Self Check Audio Alerts
authorJosh Stompro <stompro@stompro.org>
Tue, 25 May 2021 14:42:22 +0000 (09:42 -0500)
committerGalen Charlton <gmc@equinoxOLI.org>
Thu, 12 Aug 2021 13:54:59 +0000 (09:54 -0400)
The method of playing audio alerts seems to not be working in modern browsers.

It seemed to work in firefox V40, but no longer in V68.

Adding the autoplay element and then immediately removing it prevents the audio
from playing.  I've also noticed in the past that the audio had been cut off
before the file was fully played.

Using the .play() method does seem to work in newer versions of Firefox
and Chrome.  Tested with Chrome V90 and Firefox V78.10.1esr.

Testing Plan:

1. Enable Self Check Audio Alerts Library Setting.
2. See the docs for setting up the default audio alerts.
https://docs.evergreen-ils.org/reorg/3.1/command_line_admin/_self_check_interface.html
3. Launch self check interface, create a workstation and try to trigger an alert.
https://eg-server.you.com/eg/circ/selfcheck/main
4. entering a fake barcode will trigger an alert which should not be audible.

Apply the fix:

1. Launch self check interface, and reload/clear cache.
2. Enter a fake barcode to trigger an audio alert.
3. The audio alert should now be audible.

Signed-off-by: Josh Stompro <stompro@stompro.org>
Signed-off-by: Erica Rohlfs <erica.rohlfs@equinoxOLI.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>

Open-ILS/web/js/dojo/openils/Util.js

index e3588ae..d48cb06 100644 (file)
@@ -356,11 +356,8 @@ if(!dojo._hasResource["openils.Util"]) {
      */
     openils.Util.playAudioUrl = function(urlString) {
         if(!urlString) return;
-        var audio = document.createElement('audio');
-        audio.setAttribute('src', urlString);
-        audio.setAttribute('autoplay', 'true');
-        document.body.appendChild(audio);
-        document.body.removeChild(audio);
+        var audio = new Audio(urlString);
+        audio.play();
     }
 
     /**