Skip to content

Commit 2966988

Browse files
committed
dbus_mpris: fix track indexing for OpenUri
Fixes #1377.
1 parent 7de2aad commit 2966988

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/dbus_mpris.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use librespot_connect::{LoadContextOptions, LoadRequest, LoadRequestOptions, Spi
1717
use librespot_core::{Session, SpotifyUri};
1818
use librespot_metadata::audio::AudioItem;
1919
use librespot_playback::player::PlayerEvent;
20-
use log::{debug, error, warn};
20+
use log::{debug, warn};
2121
use std::convert::TryFrom;
2222
use std::{
2323
collections::HashMap,
@@ -751,7 +751,10 @@ fn register_player_interface(
751751
Ok::<_, librespot_core::Error>(match uri {
752752
SpotifyUri::Track { .. } => {
753753
let track = Track::get(&session, &uri).await?;
754-
(track.number as u32, track.album.id.to_uri()?)
754+
if track.number == 0 {
755+
warn!("track.number is not expected to be 0- but 1-indexed");
756+
}
757+
((track.number - 1).max(0) as u32, track.album.id.to_uri()?)
755758
}
756759
SpotifyUri::Album { .. }
757760
| SpotifyUri::Artist { .. }

0 commit comments

Comments
 (0)