From 8207422459bce7fc3ca3f919ef426e54eaa826b0 Mon Sep 17 00:00:00 2001 From: Florrie Date: Mon, 4 Jun 2018 23:47:18 -0300 Subject: Escape to stop playing current track E.g. queue whatever album you want to play, press escape to stop playing the current track, press 2 to focus the queue, S to shuffle, then play the first track. (If you don't stop the current track first, that track won't be shuffled with the rest.) --- README.md | 1 + ui.js | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 2e9e26e..d971733 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ * Shift+Up - play previous track * Shift+Down - play next track * Space, p, or k - toggle pause +* Escape - stop playing the current track * Right or l - seek ahead * Left or j - seek back * **In the main listing:** diff --git a/ui.js b/ui.js index 6e7aad1..7a524ee 100644 --- a/ui.js +++ b/ui.js @@ -135,6 +135,8 @@ class AppElement extends FocusElement { this.seekBack(10) } else if (telc.isCaselessLetter(keyBuf, 'p') || telc.isCaselessLetter(keyBuf, 'k')) { this.togglePause() + } else if (telc.isEscape(keyBuf)) { + this.clearPlayingTrack() } else if (telc.isShiftUp(keyBuf)) { this.playPreviousTrack(this.playingTrack) } else if (telc.isShiftDown(keyBuf)) { @@ -190,6 +192,13 @@ class AppElement extends FocusElement { this.player.togglePause() } + stopPlaying() { + // We emit this so playTrack doesn't immediately start a new track. + // We aren't *actually* about to play a new track. + this.emit('playing new track') + this.player.kill() + } + async queueGrouplikeItem(topItem, play = true, afterItem = null) { const newTrackIndex = this.queueGrouplike.items.length @@ -367,6 +376,7 @@ class AppElement extends FocusElement { clearPlayingTrack() { this.playingTrack = null + this.stopPlaying() this.playbackInfoElement.clearInfo() } } -- cgit 1.3.0-6-gf8a5