Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ffe7cd0090 | |||
| 907a734be3 | |||
| 135700ce02 |
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-player"
|
||||
version = "0.1.15"
|
||||
version = "0.1.18"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -183,8 +183,10 @@ async fn run_app<B: ratatui::backend::Backend>(
|
||||
let new_position = player.get_position().unwrap_or(0.0);
|
||||
let new_duration = player.get_duration().unwrap_or(0.0);
|
||||
|
||||
// Only mark as changed if position moved by at least 0.5 seconds
|
||||
if (new_position - last_position).abs() >= 0.5 {
|
||||
// Only update if displayed value (rounded to seconds) changed
|
||||
let old_display_secs = last_position as u32;
|
||||
let new_display_secs = new_position as u32;
|
||||
if new_display_secs != old_display_secs {
|
||||
state.current_position = new_position;
|
||||
last_position = new_position;
|
||||
state_changed = true;
|
||||
|
||||
@@ -249,13 +249,6 @@ impl Player {
|
||||
self.is_idle = idle;
|
||||
}
|
||||
}
|
||||
|
||||
// Update cache duration (how many seconds are buffered ahead)
|
||||
if let Some(val) = self.get_property("demuxer-cache-duration") {
|
||||
self.cache_duration = val.as_f64();
|
||||
} else {
|
||||
self.cache_duration = None;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_metadata(&mut self) {
|
||||
@@ -313,6 +306,13 @@ impl Player {
|
||||
if let Some(val) = self.get_property("audio-params/samplerate") {
|
||||
self.sample_rate = val.as_i64();
|
||||
}
|
||||
|
||||
// Update cache duration (how many seconds are buffered ahead)
|
||||
if let Some(val) = self.get_property("demuxer-cache-duration") {
|
||||
self.cache_duration = val.as_f64();
|
||||
} else {
|
||||
self.cache_duration = None;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_position(&self) -> Option<f64> {
|
||||
|
||||
@@ -536,7 +536,7 @@ fn render_status_bar(frame: &mut Frame, state: &AppState, player: &Player, area:
|
||||
|
||||
if let Some(cache_dur) = player.cache_duration {
|
||||
if cache_dur > 0.0 {
|
||||
right_parts.push(format!("Cache:{:.1}s", cache_dur));
|
||||
right_parts.push(format!("{:.1}s", cache_dur));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user