remaining time instead of total time in progrss bar
This commit is contained in:
11
src/app.rs
11
src/app.rs
@@ -195,7 +195,10 @@ impl App {
|
||||
self.player.pause();
|
||||
}
|
||||
}
|
||||
Action::UpdateQueue => self.queue_state.select_first(),
|
||||
Action::UpdateQueue => {
|
||||
self.queue_state.select_first();
|
||||
self.player.current_idx = 0;
|
||||
}
|
||||
Action::Next => self.player.skip_next(),
|
||||
Action::Previous => {
|
||||
let index = self.player.current_idx;
|
||||
@@ -238,8 +241,7 @@ impl Widget for &mut App {
|
||||
Mode::Help => {}
|
||||
Mode::Popup => {}
|
||||
Mode::Quit => {}
|
||||
Mode::Queue =>
|
||||
StatefulWidget::render(
|
||||
Mode::Queue => StatefulWidget::render(
|
||||
&Queue::new(self.player.songs_list.clone(), self.player.current_idx),
|
||||
layout[0],
|
||||
buf,
|
||||
@@ -247,8 +249,7 @@ impl Widget for &mut App {
|
||||
),
|
||||
};
|
||||
|
||||
|
||||
Widget::render(&Progress::new(&self.player), layout[1],buf);
|
||||
Widget::render(&Progress::new(&self.player), layout[1], buf);
|
||||
|
||||
if let Some((title, message)) = &mut self.popup {
|
||||
let block = Block::bordered().title(title.as_str());
|
||||
|
||||
@@ -20,7 +20,7 @@ impl<'a> Progress<'a> {
|
||||
impl Widget for &Progress<'_> {
|
||||
fn render(self, area: ratatui::prelude::Rect, buf: &mut ratatui::prelude::Buffer) {
|
||||
let ratio = self.player.ratio_played();
|
||||
let pos = self.player.current_pos_duration().as_secs();
|
||||
let current_pos = self.player.current_pos_duration().as_secs();
|
||||
if let Some(song) = &self
|
||||
.player
|
||||
.current_song {
|
||||
@@ -52,19 +52,19 @@ impl Widget for &Progress<'_> {
|
||||
|
||||
Text::from(format!(
|
||||
"{:0>2}:{:0>2}:{:0>2} ",
|
||||
pos / (60 * 60),
|
||||
pos / 60,
|
||||
pos % 60
|
||||
current_pos / (60 * 60),
|
||||
current_pos / 60,
|
||||
current_pos % 60
|
||||
))
|
||||
.right_aligned()
|
||||
.render(inner_layout[0], buf);
|
||||
|
||||
let pos = song.duration.map(|d| d.to_duration().as_secs() ).unwrap_or_default();
|
||||
let remaining_duration = song.duration.map(|d| d.to_duration().as_secs() ).unwrap_or_default() - current_pos;
|
||||
Text::from(format!(
|
||||
" {:0>2}:{:0>2}:{:0>2}",
|
||||
pos / (60 * 60),
|
||||
pos / 60,
|
||||
pos % 60
|
||||
remaining_duration / (60 * 60),
|
||||
remaining_duration / 60,
|
||||
remaining_duration % 60
|
||||
))
|
||||
.left_aligned()
|
||||
.render(inner_layout[2], buf);
|
||||
|
||||
Reference in New Issue
Block a user