Compare commits
No commits in common. "fd44d3280acbe85373aac7839416f8f577905191" and "274751a6e0064c75572ddfb6ee56a233a454c0c2" have entirely different histories.
fd44d3280a
...
274751a6e0
2 changed files with 22 additions and 30 deletions
|
@ -128,9 +128,8 @@ mod imp {
|
||||||
if new_position > self.window().duration() {
|
if new_position > self.window().duration() {
|
||||||
// just seek to the next track
|
// just seek to the next track
|
||||||
self.on_skip_forward_clicked();
|
self.on_skip_forward_clicked();
|
||||||
} else {
|
|
||||||
self.window().seek(new_position);
|
|
||||||
}
|
}
|
||||||
|
self.window().seek(new_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
|
|
|
@ -12,12 +12,12 @@ mod imp {
|
||||||
use zbus::object_server::InterfaceRef;
|
use zbus::object_server::InterfaceRef;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub(super) enum State {
|
enum State {
|
||||||
Idle,
|
Idle,
|
||||||
FileLoading,
|
FileLoading,
|
||||||
FileLoaded, // internal?
|
FileLoaded,
|
||||||
Active,
|
Active,
|
||||||
FileEnded, // internal?
|
FileEnded,
|
||||||
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 {
|
||||||
pub(super) state: Cell<State>,
|
state: Cell<State>,
|
||||||
|
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub(super) playbar: TemplateChild<crate::ui::Playbar>,
|
pub(super) playbar: TemplateChild<crate::ui::Playbar>,
|
||||||
|
@ -175,10 +175,8 @@ mod imp {
|
||||||
move || match window.upgrade() {
|
move || match window.upgrade() {
|
||||||
None => glib::ControlFlow::Break,
|
None => glib::ControlFlow::Break,
|
||||||
Some(window) => {
|
Some(window) => {
|
||||||
match window.imp().state.get() {
|
if !window.idle_active() && !window.pause() {
|
||||||
State::Idle | State::FileLoading | State::Seeking => {},
|
window.notify("time-pos");
|
||||||
State::Active => window.notify("time-pos"),
|
|
||||||
other => unreachable!("{other:?}"),
|
|
||||||
}
|
}
|
||||||
glib::ControlFlow::Continue
|
glib::ControlFlow::Continue
|
||||||
}
|
}
|
||||||
|
@ -508,9 +506,6 @@ mod imp {
|
||||||
}
|
}
|
||||||
self.state.set(State::FileLoading);
|
self.state.set(State::FileLoading);
|
||||||
|
|
||||||
// make sure this is reported as 0
|
|
||||||
self.obj().notify("time-pos");
|
|
||||||
|
|
||||||
event!(Level::INFO, "StartFile");
|
event!(Level::INFO, "StartFile");
|
||||||
self.obj().notify("song");
|
self.obj().notify("song");
|
||||||
self.buffering_start();
|
self.buffering_start();
|
||||||
|
@ -543,6 +538,9 @@ mod imp {
|
||||||
{
|
{
|
||||||
handle.abort();
|
handle.abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make sure this is reported as 0
|
||||||
|
self.obj().notify("time-pos");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_file_loaded(&self) {
|
fn on_file_loaded(&self) {
|
||||||
|
@ -598,6 +596,7 @@ mod imp {
|
||||||
|
|
||||||
event!(Level::INFO, "PlaybackRestart");
|
event!(Level::INFO, "PlaybackRestart");
|
||||||
self.buffering_end();
|
self.buffering_end();
|
||||||
|
self.obj().notify("time-pos");
|
||||||
|
|
||||||
if let Some(queued_seek) = self.queued_seek.take() {
|
if let Some(queued_seek) = self.queued_seek.take() {
|
||||||
// a seek was tried before and failed, try again now
|
// a seek was tried before and failed, try again now
|
||||||
|
@ -618,9 +617,6 @@ mod imp {
|
||||||
}
|
}
|
||||||
self.state.set(State::FileEnded);
|
self.state.set(State::FileEnded);
|
||||||
|
|
||||||
// make sure the seekbar looks full
|
|
||||||
self.obj().notify("time-pos");
|
|
||||||
|
|
||||||
self.obj().notify("song");
|
self.obj().notify("song");
|
||||||
self.buffering_end();
|
self.buffering_end();
|
||||||
|
|
||||||
|
@ -632,6 +628,9 @@ mod imp {
|
||||||
self.queued_seek.set(None);
|
self.queued_seek.set(None);
|
||||||
|
|
||||||
self.obj().set_playing_cover_art(None::<gdk::Texture>);
|
self.obj().set_playing_cover_art(None::<gdk::Texture>);
|
||||||
|
|
||||||
|
// make sure the seekbar looks full
|
||||||
|
self.obj().notify("time-pos");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
|
@ -761,23 +760,17 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn seek(&self, new_position: f64) {
|
pub fn seek(&self, new_position: f64) {
|
||||||
use imp::State;
|
match self
|
||||||
|
.imp()
|
||||||
match self.imp().state.get() {
|
|
||||||
State::Active | State::Seeking => {
|
|
||||||
self.imp()
|
|
||||||
.mpv
|
.mpv
|
||||||
.command(["seek", &new_position.to_string(), "absolute+exact"])
|
.command(["seek", &new_position.to_string(), "absolute", "exact"])
|
||||||
.unwrap();
|
{
|
||||||
}
|
Ok(()) => {}
|
||||||
|
Err(err) => {
|
||||||
State::FileLoading => {
|
event!(Level::INFO, "queuing seek to {new_position}: {err}");
|
||||||
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