restore seeking
This commit is contained in:
parent
a6378b281a
commit
5e62838371
5 changed files with 40 additions and 33 deletions
|
@ -150,6 +150,7 @@ template $AudreyUiPlaybar: Adw.Bin {
|
|||
Button {
|
||||
icon-name: "non-starred";
|
||||
valign: center;
|
||||
sensitive: bind template.idle-active inverted;
|
||||
}
|
||||
|
||||
Button {
|
||||
|
|
|
@ -13,7 +13,7 @@ pub enum Event {
|
|||
//ClientMessage(ClientMessageEvent), TODO
|
||||
VideoReconfig,
|
||||
AudioReconfig,
|
||||
//Seek,
|
||||
Seek,
|
||||
PlaybackRestart,
|
||||
PropertyChange(PropertyEvent),
|
||||
//QueueOverflow,
|
||||
|
|
|
@ -253,6 +253,8 @@ impl Handle {
|
|||
}))
|
||||
}
|
||||
|
||||
ffi::mpv_event_id_MPV_EVENT_SEEK => Some(MpvEvent::Seek),
|
||||
|
||||
11 => Some(MpvEvent::Unknown(event.event_id)),
|
||||
|
||||
_ => todo!("event {}", event.event_id),
|
||||
|
|
|
@ -79,58 +79,42 @@ mod imp {
|
|||
fn on_play_position_seek(
|
||||
&self,
|
||||
_scroll_type: gtk::ScrollType,
|
||||
_value: f64,
|
||||
value: f64,
|
||||
_range: >k::Range,
|
||||
) -> bool {
|
||||
/*
|
||||
let playbin = self.playbin.upgrade().unwrap();
|
||||
if range.adjustment().lower() < range.adjustment().upper() {
|
||||
playbin.seek(value);
|
||||
}
|
||||
false*/
|
||||
todo!()
|
||||
self.window().seek(value);
|
||||
false
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn on_skip_forward_clicked(&self) {
|
||||
/*
|
||||
let playbin = self.playbin.upgrade().unwrap();
|
||||
playbin.go_to_next_track();*/
|
||||
todo!()
|
||||
self.window().playlist_next();
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn on_skip_backward_clicked(&self) {
|
||||
/*
|
||||
let playbin = self.playbin.upgrade().unwrap();
|
||||
playbin.go_to_prev_track();*/
|
||||
todo!()
|
||||
self.window().playlist_prev();
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn seek_backward(&self) {
|
||||
/*
|
||||
let playbin = self.playbin.upgrade().unwrap();
|
||||
// 10 seconds
|
||||
let mut new_position = playbin.position() - 10.0;
|
||||
let mut new_position = self.window().time_pos() - 10.0;
|
||||
if new_position < 0.0 {
|
||||
new_position = 0.0;
|
||||
}
|
||||
playbin.seek(new_position);*/
|
||||
todo!()
|
||||
self.window().seek(new_position);
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn seek_forward(&self) {
|
||||
/*
|
||||
let playbin = self.playbin.upgrade().unwrap();
|
||||
// 10 seconds
|
||||
let mut new_position = playbin.position() + 10.0;
|
||||
if new_position > playbin.duration() {
|
||||
new_position = playbin.duration();
|
||||
let new_position = self.window().time_pos() + 10.0;
|
||||
if new_position > self.window().duration() {
|
||||
// just seek to the next track
|
||||
self.on_skip_forward_clicked();
|
||||
}
|
||||
playbin.seek(new_position);*/
|
||||
todo!()
|
||||
self.window().seek(new_position);
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
|
|
|
@ -403,10 +403,15 @@ mod imp {
|
|||
.unwrap();
|
||||
|
||||
// sanity check
|
||||
assert_eq!(
|
||||
song.stream_url(),
|
||||
self.mpv.get_property::<String>("path").unwrap()
|
||||
);
|
||||
match self.mpv.get_property::<String>("path") {
|
||||
Ok(path) => assert_eq!(song.stream_url(), path),
|
||||
Err(err) if err.is_property_unavailable() => {
|
||||
// NOTE: this happens between EndFile and StartFile
|
||||
event!(Level::WARN, "can't do sanity check, path is unavailable")
|
||||
}
|
||||
Err(err) => Err(err).unwrap(),
|
||||
};
|
||||
|
||||
Some(song)
|
||||
}
|
||||
}
|
||||
|
@ -463,4 +468,19 @@ impl Window {
|
|||
self.imp().api.replace(Some(Rc::new(api)));
|
||||
self.set_can_click_shuffle_all(true);
|
||||
}
|
||||
|
||||
pub fn playlist_next(&self) {
|
||||
self.imp().mpv.command(["playlist-next"]).unwrap();
|
||||
}
|
||||
|
||||
pub fn playlist_prev(&self) {
|
||||
self.imp().mpv.command(["playlist-prev"]).unwrap();
|
||||
}
|
||||
|
||||
pub fn seek(&self, new_position: f64) {
|
||||
self.imp()
|
||||
.mpv
|
||||
.command(["seek", &new_position.to_string(), "absolute", "exact"])
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue