From: Steinar H. Gunderson Date: Sat, 22 Nov 2014 11:13:14 +0000 (+0100) Subject: Explicitly prefer Opus over MP3. X-Git-Url: https://git.sesse.net/?p=remoteglot;a=commitdiff_plain;h=5bc76692a719362858abbf89c6808b544890dfe4 Explicitly prefer Opus over MP3. --- 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");