Mercurial > beefweb_mpris
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 3:18f743c980fa | 4:26f695129c86 |
|---|---|
| 204 return Ok(()); | 204 return Ok(()); |
| 205 } | 205 } |
| 206 | 206 |
| 207 async fn seek(&self, offset: mpris_server::Time) -> fdo::Result<()> | 207 async fn seek(&self, offset: mpris_server::Time) -> fdo::Result<()> |
| 208 { | 208 { |
| 209 let pl = self.bw.set_position(time_to_secs(offset)).await; | 209 let pl = self.bw.seek(time_to_secs(offset)).await; |
| 210 | 210 |
| 211 match pl { | 211 match pl { |
| 212 Err(_) => return Err(fdo::Error::Failed("uhoh".to_string())), | 212 Err(_) => return Err(fdo::Error::Failed("uhoh".to_string())), |
| 213 _ => (), | 213 _ => (), |
| 214 }; | 214 }; |
| 311 match track.columns.get(4).unwrap().parse::<i32>() { | 311 match track.columns.get(4).unwrap().parse::<i32>() { |
| 312 Ok(v) => { x.set_track_number(Some(v)); }, | 312 Ok(v) => { x.set_track_number(Some(v)); }, |
| 313 _ => (), | 313 _ => (), |
| 314 }; | 314 }; |
| 315 x.set_album_artist(Some([track.columns.get(5).unwrap()])); | 315 x.set_album_artist(Some([track.columns.get(5).unwrap()])); |
| 316 x.set_trackid(format!("/org/foobar2000/foobar2000/trackids/{}", hex::encode(track.columns.get(6).unwrap()))); | |
| 316 /* Why is this an i32 ??? It would make more sense as f32 or f64 */ | 317 /* Why is this an i32 ??? It would make more sense as f32 or f64 */ |
| 317 match track.columns.get(7).unwrap().parse::<i32>() { | 318 match track.columns.get(7).unwrap().parse::<i32>() { |
| 318 Ok(v) => { x.set_audio_bpm(Some(v)) }, | 319 Ok(v) => { x.set_audio_bpm(Some(v)) }, |
| 319 _ => (), | 320 _ => (), |
| 320 }; | 321 }; |
| 418 async fn maximum_rate(&self) -> fdo::Result<mpris_server::PlaybackRate> | 419 async fn maximum_rate(&self) -> fdo::Result<mpris_server::PlaybackRate> |
| 419 { | 420 { |
| 420 return Ok(mpris_server::PlaybackRate::default()); | 421 return Ok(mpris_server::PlaybackRate::default()); |
| 421 } | 422 } |
| 422 | 423 |
| 423 /* WTF is this supposed to do? --paper */ | 424 /* FIXME to implement this we would have to search through each playlist |
| 425 * for the track, and if it doesn't exist, append it to the current playlist. | |
| 426 * | |
| 427 * THEN we can add it directly into the play queue. */ | |
| 424 async fn set_position(&self, track_id: mpris_server::TrackId, position: mpris_server::Time) -> fdo::Result<()> | 428 async fn set_position(&self, track_id: mpris_server::TrackId, position: mpris_server::Time) -> fdo::Result<()> |
| 425 { | 429 { |
| 426 return Ok(()); | 430 return Ok(()); |
| 427 } | 431 } |
| 428 | 432 |
| 429 /* Beefweb doesn't really have this, and it would be | 433 /* TODO: |
| 430 * pointless anyway, unless we used winepath */ | 434 * |
| 435 * We can effectively implement this "proper" by detecting a file:// | |
| 436 * path, URL decoding it, and prepending "Z:". */ | |
| 431 async fn open_uri(&self, uri: String) -> fdo::Result<()> | 437 async fn open_uri(&self, uri: String) -> fdo::Result<()> |
| 432 { | 438 { |
| 433 return Ok(()); | 439 return Ok(()); |
| 434 } | 440 } |
| 435 } | 441 } |
| 442 | |
| 443 /* -- unfinished impl, don't mind this | |
| 444 | |
| 445 | |
| 446 impl mpris_server::LocalPlaylistsInterface for BeefwebPlayer { | |
| 447 async fn activate_playlist(&self, playlist_id: mpris_server::PlaylistId) -> fdo::Result<()> | |
| 448 { | |
| 449 return Err(fdo::Error::Failed("uhoh".to_string())); | |
| 450 } | |
| 451 | |
| 452 async fn get_playlists(&self, index: u32, max_count: u32, order: mpris_server::PlaylistOrdering, reverse_order: bool) -> fdo::Result<Vec<mpris_server::Playlist>> | |
| 453 { | |
| 454 let mut v: Vec<mpris_server::Playlist> = Vec::new(); | |
| 455 | |
| 456 let playlists = self.bw.playlists().await; | |
| 457 | |
| 458 match playlists { | |
| 459 Ok(ref v) => (), | |
| 460 _ => return Err(fdo::Error::Failed("req failed".to_string())), | |
| 461 } | |
| 462 | |
| 463 for playlist in playlists.unwrap() { | |
| 464 | |
| 465 } | |
| 466 | |
| 467 return Err(fdo::Error::Failed("uhoh".to_string())); | |
| 468 } | |
| 469 | |
| 470 async fn playlist_count(&self) -> fdo::Result<u32> | |
| 471 { | |
| 472 return Err(fdo::Error::Failed("unimpl".to_string())); | |
| 473 } | |
| 474 | |
| 475 async fn orderings(&self) -> fdo::Result<Vec<mpris_server::PlaylistOrdering>> | |
| 476 { | |
| 477 todo!() | |
| 478 } | |
| 479 | |
| 480 async fn active_playlist(&self) -> fdo::Result<Option<mpris_server::Playlist>> | |
| 481 { | |
| 482 todo!() | |
| 483 } | |
| 484 } | |
| 485 */ |
