aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpacien2024-01-05 02:39:01 +0100
committerpacien2024-01-05 02:39:01 +0100
commit04c9838ab593306c84918850a608aceafb01999c (patch)
tree191d3fae44fabb8ec88cc97bab0650f49835ffb6
parent95cbf08f037cf2ef63262d96e9ab4cc473529329 (diff)
downloadechoclip-04c9838ab593306c84918850a608aceafb01999c.tar.gz
reset position only when playing
-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