diff options
author | Florrie <towerofnix@gmail.com> | 2018-01-24 17:44:42 -0400 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-01-24 17:45:34 -0400 |
commit | a22688a0f04920c73a06a7c1be09037c4de8f0ce (patch) | |
tree | 480756441709de3ca6c43c550d34936a3ccc2c24 | |
parent | ed54217c7b1f720ce817a6df10f4f9920e815e5f (diff) |
Add paused indicator for mpv player
-rw-r--r-- | src/loop-play.js | 15 | ||||
-rw-r--r-- | todo.txt | 1 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/loop-play.js b/src/loop-play.js index 34ac4d5..70b5e5c 100644 --- a/src/loop-play.js +++ b/src/loop-play.js @@ -22,8 +22,11 @@ const { getItemPathString, safeUnlink, parentSymbol } = require('./playlist-utils') -function createStatusLine({percentStr, curStr, lenStr}) { - return `(${percentStr}) ${curStr} / ${lenStr}` +function createStatusLine({percentStr, curStr, lenStr, paused = false}) { + return ( + `(${percentStr}) ${curStr} / ${lenStr}` + + (paused === true ? ' (Paused)' : '') + ) } class Player extends EventEmitter { @@ -31,6 +34,7 @@ class Player extends EventEmitter { super() this.disablePlaybackStatus = false + this.paused = false } playFile(file) {} @@ -99,7 +103,9 @@ class MPVPlayer extends Player { (Math.trunc(percentVal * 100) / 100).toFixed(2) + '%' ) - this.printStatusLine(createStatusLine({percentStr, curStr, lenStr})) + this.printStatusLine(createStatusLine({ + percentStr, curStr, lenStr, paused: this.paused + })) } }) @@ -150,6 +156,7 @@ class ControllableMPVPlayer extends MPVPlayer { togglePause() { this.sendCommand('cycle pause') + this.paused = !this.paused } kill() { @@ -217,6 +224,8 @@ class SoXPlayer extends Player { lenStr = `${lenMin}:${pad(lenSec)}` } + // No need to pass paused to createStatusLine, since the SoX player + // can never be paused! this.printStatusLine(createStatusLine({percentStr, curStr, lenStr})) } } diff --git a/todo.txt b/todo.txt index 06f1c51..a08b3d9 100644 --- a/todo.txt +++ b/todo.txt @@ -161,6 +161,7 @@ TODO: The results of pressing key commands aren't very clear currently. Useful things that come to mind would be presenting the volume when it's changed; making it clear that a song is being skipped when it is; and having "paused" be part of the status bar. + (Done!) TODO: Figure out a way to make the same mpv process be reused, so that options such as volume can be remembered. (At the moment volume is reset to the |