summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeah (ctucx) <leah@ctu.cx>2021-03-05 21:02:29 +0100
committerLeah (ctucx) <leah@ctu.cx>2021-03-05 21:02:29 +0100
commit299f2c26a867bdb5c05fdf107570dfa776531d7e (patch)
tree3f93d55d734e302c5c29e4b4555969d35a8f8790
parent900a52153d88038f465c85c9b106af341a6cc096 (diff)
downloadwebmusic-nginx-299f2c26a867bdb5c05fdf107570dfa776531d7e.tar.gz
webmusic-nginx-299f2c26a867bdb5c05fdf107570dfa776531d7e.tar.bz2
webmusic-nginx-299f2c26a867bdb5c05fdf107570dfa776531d7e.zip
Add new key-commands: alias space with p, seeking with arrowkeys left/right, jumping between tracks with arrowkey up/down
-rw-r--r--webmusic.js24
1 files changed, 22 insertions, 2 deletions
diff --git a/webmusic.js b/webmusic.js
index 4dd6e00..24de390 100644
--- a/webmusic.js
+++ b/webmusic.js
@@ -21,8 +21,12 @@ window.onload = function () {
};
window.onkeyup = function (event) {
- if (event.key === "p") {
- togglePlayback();
+ if (event.key === " " || event.key === "p") {
+ if (gstate !== "idle") {
+ togglePlayback();
+ } else {
+ playSong(queue[0])
+ }
}
else if (event.key === "r") {
toggleRepeat();
@@ -30,6 +34,22 @@ window.onkeyup = function (event) {
else if (event.key === "c") {
toggleContinue();
}
+ else if (event.key === "ArrowUp") {
+ previousTrack();
+ }
+ else if (event.key === "ArrowDown") {
+ nextTrack();
+ }
+ else if (event.key === "ArrowLeft") {
+ if (sound.seek() < 10) {
+ sound.seek(0);
+ } else {
+ sound.seek(sound.seek()-10);
+ }
+ }
+ else if (event.key === "ArrowRight") {
+ sound.seek(sound.seek()+10);
+ }
};