aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-07-06 15:58:01 +0200
committersalmonik <raisersoft@proton.me>2026-07-06 15:58:01 +0200
commitfdfe24213d70b5548fb09051a0e32b7224210231 (patch)
treeced63779d57e44fa35a896b27bf07e9eee120d5f
parentadd MPRIS support and non-blocking notifs (diff)
downloadrsplayer-fdfe24213d70b5548fb09051a0e32b7224210231.tar.gz
rsplayer-fdfe24213d70b5548fb09051a0e32b7224210231.zip
add track index to MPRIS
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/mpris.rs5
-rw-r--r--src/queue.rs3
-rw-r--r--tests/daemon.rs1
-rw-r--r--tests/queue.rs2
6 files changed, 12 insertions, 3 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 0c3c6af..acf5ce5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,7 +4,7 @@ version = 4
4 4
5[[package]] 5[[package]]
6name = "RSPlayer" 6name = "RSPlayer"
7version = "0.9.0" 7version = "0.9.1"
8dependencies = [ 8dependencies = [
9 "clap", 9 "clap",
10 "clap_complete", 10 "clap_complete",
diff --git a/Cargo.toml b/Cargo.toml
index e795707..ce8ca48 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
1[package] 1[package]
2name = "RSPlayer" 2name = "RSPlayer"
3version = "0.9.0" 3version = "0.9.1"
4edition = "2024" 4edition = "2024"
5description = "Rust music player daemon with Unix socket IPC" 5description = "Rust music player daemon with Unix socket IPC"
6license = "GPL-3.0 or later" 6license = "GPL-3.0 or later"
diff --git a/src/mpris.rs b/src/mpris.rs
index 0c637c0..a7ac360 100644
--- a/src/mpris.rs
+++ b/src/mpris.rs
@@ -128,7 +128,10 @@ fn build_metadata(track: &Track) -> HashMap<String, Value<'static>> {
128 Value::new(track.album.clone().unwrap_or_default()), 128 Value::new(track.album.clone().unwrap_or_default()),
129 ); 129 );
130 130
131 map.insert("xesam:trackNumber".into(), Value::new(0i32)); 131 map.insert(
132 "xesam:trackNumber".into(),
133 Value::new(track.track_number.unwrap_or(0)),
134 );
132 135
133 map 136 map
134} 137}
diff --git a/src/queue.rs b/src/queue.rs
index 7675ddd..1f2f0fc 100644
--- a/src/queue.rs
+++ b/src/queue.rs
@@ -98,6 +98,7 @@ pub struct Track {
98 pub title: Option<String>, 98 pub title: Option<String>,
99 pub artist: Option<String>, 99 pub artist: Option<String>,
100 pub album: Option<String>, 100 pub album: Option<String>,
101 pub track_number: Option<i32>,
101 pub duration_secs: Option<f64>, 102 pub duration_secs: Option<f64>,
102 pub is_stream: bool, 103 pub is_stream: bool,
103} 104}
@@ -115,6 +116,7 @@ impl Track {
115 title: metadata.and_then(|m| m.title.clone()), 116 title: metadata.and_then(|m| m.title.clone()),
116 artist: metadata.and_then(|m| m.artist.clone()), 117 artist: metadata.and_then(|m| m.artist.clone()),
117 album: metadata.and_then(|m| m.album.clone()), 118 album: metadata.and_then(|m| m.album.clone()),
119 track_number: metadata.and_then(|m| m.track_number),
118 duration_secs: metadata.and_then(|m| m.duration_secs), 120 duration_secs: metadata.and_then(|m| m.duration_secs),
119 is_stream: false, 121 is_stream: false,
120 } 122 }
@@ -139,6 +141,7 @@ impl Track {
139 title: Some(title), 141 title: Some(title),
140 artist: None, 142 artist: None,
141 album: None, 143 album: None,
144 track_number: None,
142 duration_secs: None, 145 duration_secs: None,
143 is_stream: true, 146 is_stream: true,
144 } 147 }
diff --git a/tests/daemon.rs b/tests/daemon.rs
index e5cb270..01241fd 100644
--- a/tests/daemon.rs
+++ b/tests/daemon.rs
@@ -26,6 +26,7 @@ fn test_scrobble_state_clear() {
26 title: Some("Test".into()), 26 title: Some("Test".into()),
27 artist: Some("Artist".into()), 27 artist: Some("Artist".into()),
28 album: None, 28 album: None,
29 track_number: None,
29 duration_secs: Some(200.0), 30 duration_secs: Some(200.0),
30 is_stream: false, 31 is_stream: false,
31 }; 32 };
diff --git a/tests/queue.rs b/tests/queue.rs
index 59311d2..2eaa6f3 100644
--- a/tests/queue.rs
+++ b/tests/queue.rs
@@ -14,6 +14,7 @@ fn track(path: &str, title: Option<&str>, artist: Option<&str>, album: Option<&s
14 title: title.map(|s| s.to_string()), 14 title: title.map(|s| s.to_string()),
15 artist: artist.map(|s| s.to_string()), 15 artist: artist.map(|s| s.to_string()),
16 album: album.map(|s| s.to_string()), 16 album: album.map(|s| s.to_string()),
17 track_number: None,
17 duration_secs: None, 18 duration_secs: None,
18 is_stream: false, 19 is_stream: false,
19 } 20 }
@@ -25,6 +26,7 @@ fn track_no_meta(path: &str) -> Track {
25 title: None, 26 title: None,
26 artist: None, 27 artist: None,
27 album: None, 28 album: None,
29 track_number: None,
28 duration_secs: None, 30 duration_secs: None,
29 is_stream: false, 31 is_stream: false,
30 } 32 }