ununwrap
This commit is contained in:
parent
0aa7984092
commit
e4c54dc6f5
1 changed files with 9 additions and 16 deletions
|
@ -4,7 +4,7 @@ use gtk::glib::SendWeakRef;
|
|||
use std::collections::HashMap;
|
||||
use tracing::{event, Level};
|
||||
use zbus::object_server::{InterfaceRef, SignalEmitter};
|
||||
use zbus::zvariant::{ObjectPath, OwnedValue, Value};
|
||||
use zbus::zvariant::{ObjectPath, Value};
|
||||
|
||||
pub const MICROSECONDS: f64 = 1e6; // in a second
|
||||
|
||||
|
@ -153,21 +153,17 @@ impl Player {
|
|||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn metadata(&self) -> HashMap<&'static str, OwnedValue> {
|
||||
fn metadata(&self) -> HashMap<&'static str, Value<'_>> {
|
||||
let mut map = HashMap::new();
|
||||
|
||||
if let Some(song) = self.window().song() {
|
||||
map.insert(
|
||||
"mpris:trackid",
|
||||
Value::new(format!("/eu/callcc/audrey/Track/{}", song.counter()))
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
Value::new(format!("/eu/callcc/audrey/Track/{}", song.counter())).to_owned(),
|
||||
);
|
||||
map.insert(
|
||||
"mpris:length",
|
||||
Value::new((self.window().duration() * MICROSECONDS) as i64)
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
Value::new((self.window().duration() * MICROSECONDS) as i64),
|
||||
);
|
||||
map.insert(
|
||||
"mpris:artUrl",
|
||||
|
@ -176,15 +172,12 @@ impl Player {
|
|||
.unwrap()
|
||||
.to_string(),
|
||||
)
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
.to_owned(),
|
||||
);
|
||||
map.insert("xesam:album", Value::new(song.album()).try_into().unwrap());
|
||||
map.insert(
|
||||
"xesam:artist",
|
||||
Value::new(vec![song.artist()]).try_into().unwrap(),
|
||||
);
|
||||
map.insert("xesam:title", Value::new(song.title()).try_into().unwrap());
|
||||
map.insert("xesam:album", Value::new(song.album()));
|
||||
// TODO: use the right opensubsonic data
|
||||
map.insert("xesam:artist", Value::new(vec![song.artist()]));
|
||||
map.insert("xesam:title", Value::new(song.title()));
|
||||
}
|
||||
|
||||
map
|
||||
|
|
Loading…
Reference in a new issue