Skip to content

Instantly share code, notes, and snippets.

@mihkell
Created May 14, 2020 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mihkell/4154bb2f3f35ca9513f7b774ad8766b9 to your computer and use it in GitHub Desktop.
Save mihkell/4154bb2f3f35ca9513f7b774ad8766b9 to your computer and use it in GitHub Desktop.
Plays sound after x seconds
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script>
function out() {
x = document.getElementById('a').value;
intrvl = setInterval("sound()", x*1000);
}
function sound()
{
document.getElementById('player').play();
}
</script>
Repeat sound every x seconds
<input type="text" id="a">
<input type="button" value="sec" id="s" onclick="out()">
<audio id="player" src="https://www.soundjay.com/human/sounds/bone-crack-1.mp3"></audio>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment