X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Fjs%2Fremoteglot.js;h=3574453fa411b31bdaa926650437cd26a16cde98;hb=5bc76692a719362858abbf89c6808b544890dfe4;hp=a37fede21d8d44cd7a821e0946d681662f090eac;hpb=7bea925ab1f4de8036939bb6a5a8016492fba872;p=remoteglot diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index a37fede..3574453 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -145,7 +145,7 @@ var possibly_play_sound = function(old_data, new_data) { return; } var ding = document.getElementById('ding'); - if (ding && ding.play !== undefined) { + if (ding && ding.play) { if (old_data['position'] && old_data['position']['fen'] && new_data['position'] && new_data['position']['fen'] && (old_data['position']['fen'] !== new_data['position']['fen'] || @@ -963,6 +963,14 @@ var set_sound = function(param_enable_sound) { if (enable_sound) { $("#soundon").html("On"); $("#soundoff").html("Off"); + + // Seemingly at least Firefox prefers MP3 over Opus; tell it otherwise, + // and also preload the file since the user has selected audio. + var ding = document.getElementById('ding'); + if (ding && ding.canPlayType && ding.canPlayType('audio/ogg; codecs="opus"') === 'probably') { + ding.src = 'ding.opus'; + ding.load(); + } } else { $("#soundon").html("On"); $("#soundoff").html("Off");