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