just use the notify mechanism for time-pos

This commit is contained in:
Erica Z 2024-11-05 09:36:24 +01:00
parent f016778f5e
commit 6ed96cddb4

View file

@ -64,6 +64,7 @@ mod imp {
mpv.observe_property(2, "pause").unwrap(); mpv.observe_property(2, "pause").unwrap();
mpv.observe_property(3, "playlist-pos").unwrap(); mpv.observe_property(3, "playlist-pos").unwrap();
mpv.observe_property(4, "idle-active").unwrap(); mpv.observe_property(4, "idle-active").unwrap();
mpv.observe_property(5, "time-pos").unwrap();
// "Useful to drain property changes before a new file is loaded." // "Useful to drain property changes before a new file is loaded."
mpv.add_hook(0, "on_before_start_file", 0).unwrap(); mpv.add_hook(0, "on_before_start_file", 0).unwrap();
@ -147,6 +148,11 @@ mod imp {
window.notify("idle-active"); window.notify("idle-active");
} }
5 => {
assert_eq!(event.name, "time-pos");
window.notify("time-pos");
}
_ => unreachable!(), _ => unreachable!(),
}, },
@ -245,19 +251,6 @@ mod imp {
.await .await
.expect("could not register name in session bus"); .expect("could not register name in session bus");
}); });
// notify of new time-pos every 100 ms
glib::source::timeout_add_local(std::time::Duration::from_millis(100), {
let window = self.obj().downgrade();
move || {
let window = match window.upgrade() {
None => return glib::ControlFlow::Break,
Some(window) => window,
};
window.notify("time-pos");
glib::ControlFlow::Continue
}
});
} }
} }