X-Git-Url: https://git.nihav.org/?p=nihav-player.git;a=blobdiff_plain;f=sndplay%2Fsrc%2Fmain.rs;h=377c2d1b11bb7b134f3a1b9e1bd5ad287a61d175;hp=66def2b05250b0fe3f3fe5a32aa330e12c3fafec;hb=0a727e0528c2b26c5cefb9bbf13f6b356e6fb3db;hpb=b043bd0a14b04ddc4cf69b4701c2e1e6fe8e0111 diff --git a/sndplay/src/main.rs b/sndplay/src/main.rs index 66def2b..377c2d1 100644 --- a/sndplay/src/main.rs +++ b/sndplay/src/main.rs @@ -335,15 +335,18 @@ impl Player { if !self.paused { device.resume(); } + let mut no_display = false; 'main: loop { let cur_time = decoder.samplepos.saturating_sub(u64::from(device.size() / 2 / u32::from(dst_info.channels))); let full_ms = cur_time * 1000 / u64::from(arate); let timestr = format_time(full_ms); let disp_vol = if self.mute { 0 } else { self.volume }; - if !self.debug { - print!("> {} / {} {}% \r", timestr, duration_str, disp_vol); - } else { - print!("> {} / {} |{}| {}% \r", timestr, duration_str, device.size(), disp_vol); + if !no_display { + if !self.debug { + print!("> {} / {} {}% \r", timestr, duration_str, disp_vol); + } else { + print!("> {} / {} |{}| {}% \r", timestr, duration_str, device.size(), disp_vol); + } } std::io::stdout().flush().unwrap(); if device.size() < underfill_limit && !self.paused && refill_limit < (1 << 20) { @@ -403,6 +406,20 @@ impl Player { device.resume(); } }, + Command::Seek(seek_time) => { + device.pause(); + device.clear(); + let _ret = decoder.seek(seek_time); + while !eof && device.size() < refill_limit { + eof = decoder.refill(&device); + } + if eof { + break 'main; + } + if !self.paused { + device.resume(); + } + }, Command::Quit => { device.pause(); self.ended = true; @@ -449,8 +466,12 @@ impl Player { Command::Debug => { self.debug = !self.debug; }, + Command::PauseDisplay => { no_display = true; }, + Command::ResumeDisplay => { no_display = false; }, }; - print!("\r{:60}\r", ' '); + if !no_display { + print!("\r{:60}\r", ' '); + } } thread::sleep(Duration::from_millis(200)); }