format time with hours
[nihav-player.git] / sndplay / src / main.rs
index 377c2d1b11bb7b134f3a1b9e1bd5ad287a61d175..176a6d189d8e55b3821ca9c747aa17513ad4b81d 100644 (file)
@@ -193,10 +193,15 @@ fn format_time(ms: u64) -> String {
     let s = ms / 1000;
     let ds = (ms % 1000) / 100;
     let (min, s) = (s / 60, s % 60);
-    if min == 0 {
-        format!("{}.{}", s, ds)
+    let (h, min) = (min / 60, min % 60);
+    if h == 0 {
+        if min == 0 {
+            format!("{}.{}", s, ds)
+        } else {
+            format!("{}:{:02}.{}", min, s, ds)
+        }
     } else {
-        format!("{}:{:02}.{}", min, s, ds)
+        format!("{}:{:02}:{:02}.{}", h, min, s, ds)
     }
 }
 
@@ -466,8 +471,18 @@ impl Player {
                     Command::Debug => {
                         self.debug = !self.debug;
                     },
-                    Command::PauseDisplay  => { no_display = true; },
-                    Command::ResumeDisplay => { no_display = false; },
+                    Command::PauseDisplay  => {
+                        no_display = true;
+                        if !self.paused {
+                            device.pause();
+                        }
+                    },
+                    Command::ResumeDisplay => {
+                        no_display = false;
+                        if !self.paused {
+                            device.resume();
+                        }
+                    },
                 };
                 if !no_display {
                     print!("\r{:60}\r", ' ');