diff options
author | Florrie <towerofnix@gmail.com> | 2017-11-08 12:21:07 -0400 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2017-11-08 12:21:07 -0400 |
commit | 9116735f71e6f392c726006cf7ae5d46ea91ccfa (patch) | |
tree | 7ca15fb0765705d2d59551397d2ac216d3610d8f /src | |
parent | 6d454e06570b727221eff348408db51033957367 (diff) | |
parent | 69383a7c1ff7240e664c6af97f84cc7e44050f42 (diff) |
Merge branch 'master' of https://github.com/towerofnix/http-music
Diffstat (limited to 'src')
-rw-r--r-- | src/loop-play.js | 44 | ||||
-rw-r--r-- | src/playlist-utils.js | 2 |
2 files changed, 32 insertions, 14 deletions
diff --git a/src/loop-play.js b/src/loop-play.js index 01e1574..09b3cad 100644 --- a/src/loop-play.js +++ b/src/loop-play.js @@ -96,7 +96,9 @@ class MPVPlayer extends Player { const curSecTotal = (3600 * curHour) + (60 * curMin) + (1 * curSec) const lenSecTotal = (3600 * lenHour) + (60 * lenMin) + (1 * lenSec) const percentVal = (100 / lenSecTotal) * curSecTotal - const percentStr = (Math.trunc(percentVal * 100) / 100).toFixed(2) + const percentStr = ( + (Math.trunc(percentVal * 100) / 100).toFixed(2) + '%' + ) this.printStatusLine(createStatusLine({percentStr, curStr, lenStr})) } @@ -363,27 +365,43 @@ class PlayController extends EventEmitter { this.player.on('printStatusLine', playerString => { let fullStatusLine = '' + // ESC[K - clears the line going from the cursor position onwards. + // This is here to avoid artefacts from a previously printed status line. + fullStatusLine += '\x1b[K' + const track = this.currentTrack if (track) { if (track.overallTrackIndex || track.groupTrackIndex) { fullStatusLine += '(' - if (track.overallTrackIndex) { - const [ cur, len ] = track.overallTrackIndex - fullStatusLine += `${cur + 1} / ${len}` - - if (track.groupTrackIndex) { - fullStatusLine += ' [All]; ' + addTrackNumberInnards: { + if (track.overallTrackIndex) { + const [ cur, len ] = track.overallTrackIndex + fullStatusLine += `${cur + 1} / ${len}` + + if (track.groupTrackIndex) { + const [ curGroup, lenGroup ] = track.groupTrackIndex + + // If the overall and group track indexes are equal to each + // other, there's a fair chance we're just playing a single + // group; so, we only display one index (and we don't show + // "[All]"/"[Group]" labels). + if (curGroup === cur && lenGroup === len) { + break addTrackNumberInnards + } else { + fullStatusLine += ' [All]; ' + } + } } - } - if (track.groupTrackIndex) { - const [ cur, len ] = track.groupTrackIndex - fullStatusLine += `${cur + 1} / ${len}` + if (track.groupTrackIndex) { + const [ cur, len ] = track.groupTrackIndex + fullStatusLine += `${cur + 1} / ${len}` - if (track.overallTrackIndex) { - fullStatusLine += ' [Group]' + if (track.overallTrackIndex) { + fullStatusLine += ' [Group]' + } } } diff --git a/src/playlist-utils.js b/src/playlist-utils.js index c2f6aae..3983c7a 100644 --- a/src/playlist-utils.js +++ b/src/playlist-utils.js @@ -533,7 +533,7 @@ module.exports = { filterPlaylistByPathString, filterGrouplikeByPath, removeGroupByPathString, removeGroupByPath, getPlaylistTreeString, - getItemPathString, + getItemPath, getItemPathString, parsePathString, isSameTrack, getTrackIndexInParent, |