diff options
-rw-r--r-- | index.js | 54 | ||||
m--------- | tui-lib | 0 | ||||
-rw-r--r-- | ui.js | 24 |
3 files changed, 22 insertions, 56 deletions
diff --git a/index.js b/index.js index 5f592df..6a3c8f8 100644 --- a/index.js +++ b/index.js @@ -15,61 +15,7 @@ process.on('unhandledRejection', error => { process.exit(1) }) -class InternalApp extends EventEmitter { - constructor() { - super() - this.player = null - } - - async setup() { - this.player = await getPlayer() - } - - async startPlaying(arg) { - this.player.playFile(await this.download(arg)) - } - - stopPlaying() { - this.player.kill() - } - - seekAhead(seconds) { - this.player.seekAhead(seconds) - } - - seekBehind(seconds) { - this.player.seekBehind(seconds) - } - - togglePause() { - this.player.togglePause() - } - - download(arg) { - return getDownloaderFor(arg)(arg) - } -} - async function main() { - /* - const internalApp = new InternalApp() - await internalApp.setup() - - await internalApp.startPlaying('http://billwurtz.com/cable-television.mp3') - await new Promise(r => setTimeout(r, 2000)) - internalApp.togglePause() - await new Promise(r => setTimeout(r, 1000)) - internalApp.togglePause() - await new Promise(r => setTimeout(r, 2000)) - internalApp.stopPlaying() - */ - - /* - for (const item of require('./flat.json').items) { - await internalApp.download(item.downloaderArg) - } - */ - const interfacer = new CommandLineInterfacer() const size = await interfacer.getScreenSize() diff --git a/tui-lib b/tui-lib -Subproject 581c8db27bc25c74b02a1b29d795c847118c623 +Subproject f2676294c95695e2de3a7fb88eafae76d682761 diff --git a/ui.js b/ui.js index f293671..68c6d73 100644 --- a/ui.js +++ b/ui.js @@ -70,12 +70,32 @@ class AppElement extends FocusElement { } keyPressed(keyBuf) { - if (keyBuf[0] === 0x03 || keyBuf[0] === 'q'.charCodeAt(0) || keyBuf[0] === 'Q'.charCodeAt(0)) { + if (keyBuf[0] === 0x03 || telc.isCaselessLetter(keyBuf, 'q')) { this.shutdown() return } - super.keyPressed(keyBuf) + if (telc.isRight(keyBuf) || telc.isCaselessLetter(keyBuf, 'l')) { + this.seekAhead(10) + } else if (telc.isLeft(keyBuf) || telc.isCaselessLetter(keyBuf, 'j')) { + this.seekBack(10) + } else if (telc.isCaselessLetter(keyBuf, 'p') || telc.isCaselessLetter(keyBuf, 'k')) { + this.togglePause() + } else { + super.keyPressed(keyBuf) + } + } + + seekAhead(seconds) { + this.player.seekAhead(seconds) + } + + seekBack(seconds) { + this.player.seekBack(seconds) + } + + togglePause() { + this.player.togglePause() } async queueGrouplikeItem(item, play = true) { |