sure
This commit is contained in:
parent
1d9318eb92
commit
e72a690be2
1 changed files with 18 additions and 12 deletions
|
@ -12,12 +12,12 @@ mod imp {
|
||||||
use zbus::object_server::InterfaceRef;
|
use zbus::object_server::InterfaceRef;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
enum State {
|
pub(super) enum State {
|
||||||
Idle,
|
Idle,
|
||||||
FileLoading,
|
FileLoading,
|
||||||
FileLoaded,
|
FileLoaded, // internal?
|
||||||
Active,
|
Active,
|
||||||
FileEnded,
|
FileEnded, // internal?
|
||||||
Seeking,
|
Seeking,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ mod imp {
|
||||||
#[template(resource = "/eu/callcc/audrey/window.ui")]
|
#[template(resource = "/eu/callcc/audrey/window.ui")]
|
||||||
#[properties(wrapper_type = super::Window)]
|
#[properties(wrapper_type = super::Window)]
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
state: Cell<State>,
|
pub(super) state: Cell<State>,
|
||||||
|
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub(super) playbar: TemplateChild<crate::ui::Playbar>,
|
pub(super) playbar: TemplateChild<crate::ui::Playbar>,
|
||||||
|
@ -760,17 +760,23 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn seek(&self, new_position: f64) {
|
pub fn seek(&self, new_position: f64) {
|
||||||
match self
|
use imp::State;
|
||||||
.imp()
|
|
||||||
.mpv
|
match self.imp().state.get() {
|
||||||
.command(["seek", &new_position.to_string(), "absolute", "exact"])
|
State::Active | State::Seeking => {
|
||||||
{
|
self.imp()
|
||||||
Ok(()) => {}
|
.mpv
|
||||||
Err(err) => {
|
.command(["seek", &new_position.to_string(), "absolute", "exact"])
|
||||||
event!(Level::INFO, "queuing seek to {new_position}: {err}");
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
State::FileLoading => {
|
||||||
|
event!(Level::INFO, "queuing seek to {new_position}");
|
||||||
self.imp().queued_seek.set(Some(new_position));
|
self.imp().queued_seek.set(Some(new_position));
|
||||||
self.notify("time-pos");
|
self.notify("time-pos");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
other => panic!("can not seek when in state {other:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue