mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-16 22:31:03 +02:00
fix(mpris): use set_position instead of seek (#978)
This commit is contained in:
parent
ffbc851f0e
commit
040e7e64ee
1 changed files with 13 additions and 5 deletions
|
@ -290,14 +290,22 @@ impl MusicClient for Client {
|
|||
|
||||
fn seek(&self, duration: Duration) -> Result<()> {
|
||||
if let Some(player) = Self::get_player(self) {
|
||||
let pos = player.get_position().unwrap_or_default();
|
||||
// if possible, use `set_position` instead of `seek` because some players have issues with seeking
|
||||
// see https://github.com/JakeStanger/ironbar/issues/970
|
||||
if let Ok(metadata) = player.get_metadata() {
|
||||
if let Some(track_id) = metadata.track_id() {
|
||||
player.set_position(track_id, &duration)?;
|
||||
} else {
|
||||
let pos = player.get_position().unwrap_or_default();
|
||||
|
||||
let duration = duration.as_micros() as i64;
|
||||
let position = pos.as_micros() as i64;
|
||||
let duration = duration.as_micros() as i64;
|
||||
let position = pos.as_micros() as i64;
|
||||
|
||||
let seek = cmp::max(duration, 0) - position;
|
||||
let seek = cmp::max(duration, 0) - position;
|
||||
|
||||
player.seek(seek)?;
|
||||
player.seek(seek)?;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error!("Could not find player");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue