Created
July 18, 2022 15:06
-
-
Save osoda/b394dd252876da2c85b747dbe3e1bb52 to your computer and use it in GitHub Desktop.
Alarma JS con sonido, Se puede ejecutar en consola
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function play() { | |
var audio = new Audio('https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3'); | |
audio.play(); | |
} | |
function bucleReproductor(){ | |
if(stopPlay == 1){ | |
clearInterval(downloadTimer); | |
return | |
} | |
console.log('Stop Bucle: (console)') | |
console.log('stopPlay = 1') | |
play() | |
timeleft = 4, proggess = 0 | |
downloadTimer = timer(reproductor) | |
} | |
function reproductor(){ | |
bucleReproductor() | |
} | |
var timeleft = 60*30, proggess = 0, stopPlay = 0; | |
var timer = function(func = null){ | |
return setInterval(function(){ | |
console.log(timeleft) | |
if(timeleft <= 0){ | |
clearInterval(downloadTimer); | |
if(func != null) func(); | |
return | |
} | |
proggess = 10 - timeleft; | |
timeleft -= 1; | |
}, 1000); | |
}, | |
downloadTimer = timer(bucleReproductor) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment