diff src/player.rs @ 4:26f695129c86

*: fixes - seeking is actually relative - added track IDs (yes these weren't implemented yet even though they're required), of the format /org/foobar2000/foobar2000/trackids/(hex encoded file path) - added playlist fetching for a possible implementation of the playlist protocol
author Paper <paper@tflc.us>
date Sun, 05 Apr 2026 02:26:19 -0400
parents 18f743c980fa
children 8f71820abe71
line wrap: on
line diff
--- a/src/player.rs	Sat Apr 04 17:03:22 2026 -0400
+++ b/src/player.rs	Sun Apr 05 02:26:19 2026 -0400
@@ -206,7 +206,7 @@
 
 	async fn seek(&self, offset: mpris_server::Time) -> fdo::Result<()>
 	{
-		let pl = self.bw.set_position(time_to_secs(offset)).await;
+		let pl = self.bw.seek(time_to_secs(offset)).await;
 
 		match pl {
 			Err(_) => return Err(fdo::Error::Failed("uhoh".to_string())),
@@ -313,6 +313,7 @@
 				_ => (),
 			};
 			x.set_album_artist(Some([track.columns.get(5).unwrap()]));
+			x.set_trackid(format!("/org/foobar2000/foobar2000/trackids/{}", hex::encode(track.columns.get(6).unwrap())));
 			/* Why is this an i32 ??? It would make more sense as f32 or f64 */
 			match track.columns.get(7).unwrap().parse::<i32>() {
 				Ok(v) => { x.set_audio_bpm(Some(v)) },
@@ -420,16 +421,65 @@
 		return Ok(mpris_server::PlaybackRate::default());
 	}
 
-	/* WTF is this supposed to do?  --paper */
+	/* FIXME to implement this we would have to search through each playlist
+	 * for the track, and if it doesn't exist, append it to the current playlist.
+	 *
+	 * THEN we can add it directly into the play queue. */
 	async fn set_position(&self, track_id: mpris_server::TrackId, position: mpris_server::Time) -> fdo::Result<()>
 	{
 		return Ok(());
 	}
 
-	/* Beefweb doesn't really have this, and it would be
-	 * pointless anyway, unless we used winepath */
+	/* TODO:
+	 *
+	 * We can effectively implement this "proper" by detecting a file://
+	 * path, URL decoding it, and prepending "Z:". */
 	async fn open_uri(&self, uri: String) -> fdo::Result<()>
 	{
 		return Ok(());
 	}
 }
+
+/* -- unfinished impl, don't mind this
+
+
+impl mpris_server::LocalPlaylistsInterface for BeefwebPlayer {
+	async fn activate_playlist(&self, playlist_id: mpris_server::PlaylistId) -> fdo::Result<()>
+	{
+		return Err(fdo::Error::Failed("uhoh".to_string()));
+	}
+
+	async fn get_playlists(&self, index: u32, max_count: u32, order: mpris_server::PlaylistOrdering, reverse_order: bool) -> fdo::Result<Vec<mpris_server::Playlist>>
+	{
+		let mut v: Vec<mpris_server::Playlist> = Vec::new();
+
+		let playlists = self.bw.playlists().await;
+
+		match playlists {
+			Ok(ref v) => (),
+			_ => return Err(fdo::Error::Failed("req failed".to_string())),
+		}
+
+		for playlist in playlists.unwrap() {
+
+		}
+
+		return Err(fdo::Error::Failed("uhoh".to_string()));
+	}
+
+	async fn playlist_count(&self) -> fdo::Result<u32>
+	{
+		return Err(fdo::Error::Failed("unimpl".to_string()));
+	}
+
+	async fn orderings(&self) -> fdo::Result<Vec<mpris_server::PlaylistOrdering>>
+	{
+		todo!()
+	}
+
+	async fn active_playlist(&self) -> fdo::Result<Option<mpris_server::Playlist>>
+	{
+		todo!()
+	}
+}
+*/