обновление

This commit is contained in:
2026-10-13 17:38:18 +02:00
parent 255a99ed0f
commit 08a8a7cce5
6 changed files with 502 additions and 87 deletions

View File

@@ -16,7 +16,11 @@ impl AudioPlayer {
let stream_handle = OutputStreamBuilder::open_default_stream()?;
let sink = Sink::connect_new(&stream_handle.mixer());
sink.set_volume(1.0);
Ok(Self { _stream: stream_handle, sink, paused_pos: None })
Ok(Self {
_stream: stream_handle,
sink,
paused_pos: None,
})
}
pub fn play(&mut self, path: &PathBuf) -> Result<(), Box<dyn std::error::Error>> {
@@ -65,7 +69,11 @@ impl AudioPlayer {
self.sink.set_volume(v);
}
pub fn seek_by(&mut self, delta: i64, total: Duration) -> Result<Duration, Box<dyn std::error::Error>> {
pub fn seek_by(
&mut self,
delta: i64,
total: Duration,
) -> Result<Duration, Box<dyn std::error::Error>> {
let current = self.position();
let new_secs = (current.as_secs() as i64 + delta).max(0) as u64;
let mut new_pos = Duration::from_secs(new_secs);