fix: small bug with progress bar

This commit is contained in:
talwat 2026-10-30 07:40:48 +01:00
parent d86a51e933
commit f5d894a27f
4 changed files with 18 additions and 9 deletions

7
data/sfx.txt Normal file
View File

@ -0,0 +1,7 @@
noheader
https://sfxmint.com/dl/door-open-50.mp3
https://sfxmint.com/dl/door-open-10.mp3
https://sfxmint.com/dl/feedback-buzzer-20.mp3
https://sfxmint.com/dl/retro-game-explosion-54.mp3
https://sfxmint.com/dl/retro-game-explosion-51.mp3
https://sfxmint.com/dl/gore-squish-02.mp3

View File

@ -34,4 +34,4 @@ impl crate::Tasks {
media_controls, media_controls,
}) })
} }
} }

View File

@ -30,8 +30,12 @@ pub fn progress_bar(state: &ui::State, width: usize) -> String {
if let Some(x) = current.duration { if let Some(x) = current.duration {
duration = x; duration = x;
let elapsed = elapsed.as_secs() as f32 / duration.as_secs() as f32; let elapsed = elapsed
filled = (elapsed * width as f32).round() as usize; .as_secs_f32()
.round()
.clamp(0.0, duration.as_secs_f32());
let ratio = (elapsed / duration.as_secs_f32()).clamp(0.0, 1.0);
filled = (ratio * width as f32).round() as usize;
} }
} }

View File

@ -4,9 +4,7 @@
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration; use std::time::Duration;
use souvlaki::{ use souvlaki::{MediaControlEvent, MediaControls, MediaMetadata, MediaPlayback, PlatformConfig};
MediaControlEvent, MediaControls, MediaMetadata, MediaPlayback, PlatformConfig,
};
use tokio::sync::{broadcast, mpsc}; use tokio::sync::{broadcast, mpsc};
use crate::player::Current; use crate::player::Current;
@ -164,8 +162,8 @@ mod windows {
use ::windows::Win32::System::LibraryLoader::GetModuleHandleW; use ::windows::Win32::System::LibraryLoader::GetModuleHandleW;
use ::windows::Win32::UI::WindowsAndMessaging::{ use ::windows::Win32::UI::WindowsAndMessaging::{
CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, PeekMessageW, CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, PeekMessageW,
RegisterClassExW, TranslateMessage, MSG, PM_REMOVE, WINDOW_EX_STYLE, WINDOW_STYLE, RegisterClassExW, TranslateMessage, MSG, PM_REMOVE, WINDOW_EX_STYLE, WINDOW_STYLE, WM_QUIT,
WM_QUIT, WNDCLASSEXW, WNDCLASSEXW,
}; };
pub struct DummyWindow { pub struct DummyWindow {
@ -242,4 +240,4 @@ mod windows {
} }
} }
} }
} }