1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-17 14:51:04 +02:00

fix(mpris): use set_position instead of seek (#978)

This commit is contained in:
postsolar 2025-05-12 18:06:29 +03:00 committed by GitHub
parent ffbc851f0e
commit 040e7e64ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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");
}