dog shit metadata map
This commit is contained in:
parent
519424d42f
commit
6272c2ce07
1 changed files with 28 additions and 7 deletions
|
@ -1,11 +1,35 @@
|
|||
use glib::SendWeakRef;
|
||||
use gtk::glib;
|
||||
use std::collections::HashMap;
|
||||
use zbus::object_server::SignalEmitter;
|
||||
use zbus::zvariant::{ObjectPath, Value};
|
||||
use zbus::zvariant::{ObjectPath, OwnedObjectPath, Type, Value};
|
||||
|
||||
#[derive(Clone, Value, Type)]
|
||||
#[zvariant(signature = "a{sv}")]
|
||||
struct MetadataMap {
|
||||
pub trackid: OwnedObjectPath,
|
||||
// rest: TODO
|
||||
}
|
||||
|
||||
impl MetadataMap {
|
||||
fn as_hash_map(&self) -> HashMap<&'static str, Value> {
|
||||
HashMap::from([("mpris:trackid", Value::new(self.trackid.as_ref()))])
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MetadataMap {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
trackid: "/org/mpris/MediaPlayer2/TrackList/NoTrack"
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Player {
|
||||
playbin: SendWeakRef<crate::Playbin>,
|
||||
metadata: Vec<(String, String)>,
|
||||
metadata: MetadataMap,
|
||||
}
|
||||
|
||||
impl Player {
|
||||
|
@ -124,11 +148,8 @@ impl Player {
|
|||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn metadata(&self) -> Vec<(String, Value)> {
|
||||
self.metadata
|
||||
.iter()
|
||||
.map(|(k, v)| (k.clone(), v.into()))
|
||||
.collect()
|
||||
fn metadata(&self) -> HashMap<&'static str, Value> {
|
||||
self.metadata.as_hash_map()
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
|
|
Loading…
Reference in a new issue