The site has a schedule, a timer counting down the time until the next scheduled one, after the time has elapsed the sound is played. You must press a button to stop the sound.

But sometimes the sound does not play, but the function that reproduces the sound is exactly called, since the modal window also opens at this time.

Essential points of the code:

$(document).ready(function() { audio = new Audio('/sound/remind.mp3'); $("#ops_timer_modal").on('hidden.bs.modal', function () { clearInterval(timer_audio); upload(); }); }); function timer(name){ if(timer<1000) { audio.play(); if ('timer_audio' in window) clearInterval(timer_audio); timer_audio = setInterval(function() { audio.play(); }, 3000); $('#ops_timer_modal').modal('show'); $('#modal_timer_span').html("It's time for "+name); } } 

The timer function is called every second, it counts time (removed these lines from uselessness)

The console does not give any errors.

Ideas?

  • Add sound by creating on the <audio> page, and for shutdown, delete it. - CbIPoK2513
  • And if html5 is not supported? - Tarlan Mamedzadeh
  • Well then the problem .. You asked for an idea, I threw it) - CbIPoK2513

0