aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/app.js b/app.js
index 79ea6e8..7b5f4b0 100644
--- a/app.js
+++ b/app.js
@@ -23,23 +23,23 @@ function onNthClip(index, action) {
23 23
24document.addEventListener("keydown", event => { 24document.addEventListener("keydown", event => {
25 if (event.key.match(/[1-9]/)) 25 if (event.key.match(/[1-9]/))
26 onNthClip(parseInt(event.key), clip => clip.play()); 26 onNthClip(parseInt(event.key), clip => playFromStart(clip));
27}); 27});
28 28
29document.addEventListener("keyup", event => { 29document.addEventListener("keyup", event => {
30 if (event.key.match(/[1-9]/)) 30 if (event.key.match(/[1-9]/))
31 onNthClip(parseInt(event.key), clip => stopPlayer(clip)); 31 onNthClip(parseInt(event.key), clip => clip.pause());
32}); 32});
33 33
34function stopPlayer(player) { 34function playFromStart(player) {
35 player.pause(); 35 if (!player.paused) return;
36 player.currentTime = 0; 36 player.currentTime = 0;
37 player.play();
37} 38}
38 39
39function stopOtherPlayersExcept(player) { 40function stopOtherPlayersExcept(player) {
40 document.querySelectorAll("audio").forEach(other => { 41 document.querySelectorAll("audio").forEach(other => {
41 if (other != player) 42 if (other != player) other.pause();
42 stopPlayer(other);
43 }); 43 });
44} 44}
45 45