« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/ui.js b/ui.js
index 6127f0f..d9db800 100644
--- a/ui.js
+++ b/ui.js
@@ -1110,8 +1110,12 @@ class AppElement extends FocusElement {
       return acc + (metadata && metadata.duration) || 0
     }
 
-    const { curSecTotal = 0, lenSecTotal = 0 } = this.playbackInfoElement.timeData
-    const trackRemainSec = lenSecTotal - curSecTotal
+    let trackRemainSec = 0
+
+    if (this.playingTrack) {
+      const { curSecTotal = 0, lenSecTotal = 0 } = this.playbackInfoElement.timeData
+      trackRemainSec = lenSecTotal - curSecTotal
+    }
 
     const index = items.indexOf(this.playingTrack) + 1
     const aheadRemainSec = items.slice(index).reduce(durationFn, 0)