forked from zotan/webmusic
Merge pull request 'A few improvements ;)' (#1) from ctucx/webmusic:master into master
Reviewed-on: https://git.zotan.services/zotan/webmusic/pulls/1
This commit is contained in:
commit
86abe310d3
28
webmusic.js
28
webmusic.js
|
@ -20,9 +20,13 @@ window.onload = function () {
|
|||
updateState()
|
||||
};
|
||||
|
||||
document.addEventListener("keypress", function onEvent(event) {
|
||||
if (event.key === "p") {
|
||||
togglePlayback();
|
||||
window.onkeyup = function (event) {
|
||||
if (event.key === " " || event.key === "p") {
|
||||
if (gstate !== "idle") {
|
||||
togglePlayback();
|
||||
} else {
|
||||
playSong(queue[0])
|
||||
}
|
||||
}
|
||||
else if (event.key === "r") {
|
||||
toggleRepeat();
|
||||
|
@ -30,7 +34,23 @@ document.addEventListener("keypress", function onEvent(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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function togglePlayback() {
|
||||
|
|
Loading…
Reference in a new issue