play a sound every # of seconds

This plays a beep sound every # of seconds, to stop it just reload the page

  • 4 Minutes is 240
  • 4.5 Minutes is 270
  • 5 Minutes is 300

HTML

<input type="text" id="a"><input type="button" class='btn btn-primary' value="sec" id="s" onclick="out()">
<audio id="player" src="/files/wow.mp3"></audio>

Javascript

function out() {
  x = document.getElementById('a').value;
 intrvl = setInterval("sound(x)", x*1000);
}
i = 0;
function sound(x) 
{
  if(x == i)
    {
      clearInterval(intrvl);
    }
  i++;
  
 document.getElementById('player').play();
}

External Link for play a sound every # of seconds

Other Items in javascript
Page Views

This page has been viewed 133 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

âĪðŸ‘Đ‍ðŸ’ŧðŸ•đ

Random Quote
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better. You won't believe what you can accomplish by attempting the impossible with the courage to repeatedly fail better.
Unknown