diff options
author | Florrie <towerofnix@gmail.com> | 2018-04-14 17:16:04 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-04-14 17:17:20 -0300 |
commit | 624807f73cbde2dabfed35f5cc3aa83b33638c15 (patch) | |
tree | fa6e3043a8c962567bd9249ead155b6aa2f6dfa0 /src/loop-play.js | |
parent | 6e20b5d9b4dde541c270003494f4bb62700f3d04 (diff) |
Status line switcher
Diffstat (limited to 'src/loop-play.js')
-rw-r--r-- | src/loop-play.js | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/loop-play.js b/src/loop-play.js index e1e870d..9d073e5 100644 --- a/src/loop-play.js +++ b/src/loop-play.js @@ -370,7 +370,7 @@ class DownloadController extends EventEmitter { class PlayController extends EventEmitter { constructor({ player, playlist, historyController, downloadController, - statusLineTemplate = '%longIndex% (%percentDone%) %timeDone% / %duration%', + statusLineTemplates = ['%timeLeft%'], titleLineTemplate = '', useConverterOptions = true, trackDisplayFile = null // File to output current track path to. @@ -389,6 +389,8 @@ class PlayController extends EventEmitter { this.nextFile = undefined // TODO: Why isn't this null? this.stopped = false this.shouldMoveNext = true + this.statusLineTemplates = statusLineTemplates + this.statusLineIndex = statusLineTemplates.length - 1 this.failedCount = 0 this.playFailCount = 0 @@ -474,7 +476,8 @@ class PlayController extends EventEmitter { trackTitle: track.title, title: track.title }, playerData) - fullStatusLine += processTemplateString(statusLineTemplate, replacements) + fullStatusLine += processTemplateString( + statusLineTemplates[this.statusLineIndex], replacements) // Clear format - custom color codes, etc. fullStatusLine += '\x1b[0m' @@ -725,6 +728,20 @@ class PlayController extends EventEmitter { console.log(`(Next) ${getCleanMessage(tl[i])}`) } } + + nextStatusLine() { + this.statusLineIndex++ + if (this.statusLineIndex >= this.statusLineTemplates.length) { + this.statusLineIndex = 0 + } + } + + previousStatusLine() { + this.statusLineIndex-- + if (this.statusLineIndex < 0) { + this.statusLineIndex = this.statusLineTemplates.length - 1 + } + } } module.exports = async function startLoopPlay( @@ -734,7 +751,7 @@ module.exports = async function startLoopPlay( disablePlaybackStatus = false, startTrack = null, trackDisplayFile = null, - statusLineTemplate = undefined, + statusLineTemplates = undefined, titleLineTemplate = undefined } ) { @@ -780,7 +797,7 @@ module.exports = async function startLoopPlay( const playController = new PlayController({ player, playlist, historyController, downloadController, - trackDisplayFile, statusLineTemplate, titleLineTemplate + trackDisplayFile, statusLineTemplates, titleLineTemplate }) Object.assign(playController, {useConverterOptions}) |