diff options
author | liam4 <towerofnix@gmail.com> | 2017-06-26 22:16:59 -0300 |
---|---|---|
committer | liam4 <towerofnix@gmail.com> | 2017-06-26 22:16:59 -0300 |
commit | afa6c4a7eaf9bdcc17f6ad7d948557d3e982ae9a (patch) | |
tree | b839a40e9d1856d97bf4d0b0e5edca364fd5b495 /src/http-music.js | |
parent | 6d88565f91724f322b4db69d072b81ed27ed8da9 (diff) |
Controls for pause/play, seek, and volume
Diffstat (limited to 'src/http-music.js')
-rwxr-xr-x | src/http-music.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/http-music.js b/src/http-music.js index 48aff95..7686b45 100755 --- a/src/http-music.js +++ b/src/http-music.js @@ -281,6 +281,43 @@ Promise.resolve() process.stdin.setRawMode(true) process.stdin.on('data', data => { + const escModifier = Buffer.from('\x1b[') + const shiftModifier = Buffer.from('1;2') + + const esc = num => Buffer.concat([escModifier, Buffer.from([num])]) + + const shiftEsc = num => ( + Buffer.concat([escModifier, shiftModifier, Buffer.from([num])]) + ) + + if (Buffer.from([0x20]).equals(data)) { + play.togglePause() + } + + if (esc(0x43).equals(data)) { + play.seekAhead(5) + } + + if (esc(0x44).equals(data)) { + play.seekBack(5) + } + + if (shiftEsc(0x43).equals(data)) { + play.seekAhead(30) + } + + if (shiftEsc(0x44).equals(data)) { + play.seekBack(30) + } + + if (esc(0x41).equals(data)) { + play.volUp(10) + } + + if (esc(0x42).equals(data)) { + play.volDown(10) + } + if (Buffer.from('s').equals(data)) { // clearConsoleLine() // console.log( |