fix mpris voluem change notif
This commit is contained in:
parent
5032b9d3a2
commit
4c90d0f10e
2 changed files with 20 additions and 19 deletions
|
@ -3,7 +3,7 @@ use adw::prelude::*;
|
||||||
use gtk::glib::SendWeakRef;
|
use gtk::glib::SendWeakRef;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use tracing::{event, Level};
|
use tracing::{event, Level};
|
||||||
use zbus::object_server::InterfaceRef;
|
use zbus::object_server::{InterfaceRef, SignalEmitter};
|
||||||
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Value};
|
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Value};
|
||||||
|
|
||||||
const MICROSECONDS: f64 = 1e6; // in a second
|
const MICROSECONDS: f64 = 1e6; // in a second
|
||||||
|
@ -213,24 +213,6 @@ impl Player {
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
playbin.connect_notify_future_local(
|
|
||||||
"volume",
|
|
||||||
glib::clone!(
|
|
||||||
#[strong]
|
|
||||||
player_ref,
|
|
||||||
move |_, _| {
|
|
||||||
let player_ref = player_ref.clone();
|
|
||||||
async move {
|
|
||||||
let player = player_ref.get_mut().await;
|
|
||||||
player
|
|
||||||
.volume_changed(player_ref.signal_emitter())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
),
|
|
||||||
);
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,6 +279,9 @@ impl Player {
|
||||||
Err(zbus::fdo::Error::NotSupported("OpenUri".into()))
|
Err(zbus::fdo::Error::NotSupported("OpenUri".into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[zbus(signal)]
|
||||||
|
async fn seeked(emitter: &SignalEmitter<'_>, position: i64) -> zbus::Result<()>;
|
||||||
|
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
fn playback_status(&self) -> String {
|
fn playback_status(&self) -> String {
|
||||||
if self.window().idle_active() {
|
if self.window().idle_active() {
|
||||||
|
|
|
@ -413,6 +413,22 @@ mod imp {
|
||||||
|
|
||||||
fn set_volume(&self, volume: i64) {
|
fn set_volume(&self, volume: i64) {
|
||||||
self.mpv.set_property("volume", volume).unwrap();
|
self.mpv.set_property("volume", volume).unwrap();
|
||||||
|
|
||||||
|
let iface_borrowed = self.mpris_player.borrow();
|
||||||
|
let iface_ref = match iface_borrowed.as_ref() {
|
||||||
|
None => return, // zbus not set up yet
|
||||||
|
Some(iface_ref) => iface_ref.clone(),
|
||||||
|
};
|
||||||
|
glib::spawn_future_local(async move {
|
||||||
|
let iface = iface_ref.get().await;
|
||||||
|
match iface.volume_changed(iface_ref.signal_emitter()).await {
|
||||||
|
Ok(()) => {}
|
||||||
|
Err(err) => event!(
|
||||||
|
Level::ERROR,
|
||||||
|
"could not notify new volume through mpris interface: {err}"
|
||||||
|
),
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mute(&self) -> bool {
|
fn mute(&self) -> bool {
|
||||||
|
|
Loading…
Reference in a new issue