initial work for mpris cover art
This commit is contained in:
parent
3963c8404c
commit
d5d7ff882e
2 changed files with 11 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
||||||
mod player;
|
pub mod player;
|
||||||
pub use player::Player;
|
pub use player::Player;
|
||||||
|
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub struct MetadataMap {
|
||||||
// mpris
|
// mpris
|
||||||
track_id: Option<OwnedObjectPath>,
|
track_id: Option<OwnedObjectPath>,
|
||||||
length: Option<i64>,
|
length: Option<i64>,
|
||||||
art_url: Option<url::Url>,
|
art_url: Option<String>,
|
||||||
// xesam
|
// xesam
|
||||||
album: Option<String>,
|
album: Option<String>,
|
||||||
//album_artist: Option<Vec<String>>,
|
//album_artist: Option<Vec<String>>,
|
||||||
|
@ -36,6 +36,14 @@ pub struct MetadataMap {
|
||||||
user_rating: Option<f32>,
|
user_rating: Option<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn art_path() -> &'static std::path::Path {
|
||||||
|
static PATH: std::sync::OnceLock<std::path::PathBuf> = std::sync::OnceLock::new();
|
||||||
|
PATH.get_or_init(|| {
|
||||||
|
let xdg_dirs = xdg::BaseDirectories::with_prefix("audrey").expect("failed to get xdg dirs");
|
||||||
|
xdg_dirs.get_state_file("mpris-art")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
impl MetadataMap {
|
impl MetadataMap {
|
||||||
pub fn from_playbin_song(song: Option<&Song>) -> Self {
|
pub fn from_playbin_song(song: Option<&Song>) -> Self {
|
||||||
song.map(|song| MetadataMap {
|
song.map(|song| MetadataMap {
|
||||||
|
@ -46,7 +54,7 @@ impl MetadataMap {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}),
|
}),
|
||||||
length: Some(song.duration() * MICROSECONDS as i64),
|
length: Some(song.duration() * MICROSECONDS as i64),
|
||||||
//art_url: Some(song.cover_art_url()), // FIXME: this would leak credentials
|
art_url: Some(url::Url::from_file_path(art_path()).unwrap().to_string()),
|
||||||
album: Some(song.album()),
|
album: Some(song.album()),
|
||||||
artist: Some(vec![song.artist()]),
|
artist: Some(vec![song.artist()]),
|
||||||
//content_created: song.year().map(|year| chrono::NaiveDate::from_yo_opt(year, 1).unwrap()), // FIXME: replace this unwrap with Some(Err) -> None
|
//content_created: song.year().map(|year| chrono::NaiveDate::from_yo_opt(year, 1).unwrap()), // FIXME: replace this unwrap with Some(Err) -> None
|
||||||
|
|
Loading…
Reference in a new issue