обновление
This commit is contained in:
12
src/audio.rs
12
src/audio.rs
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user