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 {
|
Button {
|
||||||
icon-name: "non-starred";
|
icon-name: "non-starred";
|
||||||
valign: center;
|
valign: center;
|
||||||
|
sensitive: bind template.idle-active inverted;
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub enum Event {
|
||||||
//ClientMessage(ClientMessageEvent), TODO
|
//ClientMessage(ClientMessageEvent), TODO
|
||||||
VideoReconfig,
|
VideoReconfig,
|
||||||
AudioReconfig,
|
AudioReconfig,
|
||||||
//Seek,
|
Seek,
|
||||||
PlaybackRestart,
|
PlaybackRestart,
|
||||||
PropertyChange(PropertyEvent),
|
PropertyChange(PropertyEvent),
|
||||||
//QueueOverflow,
|
//QueueOverflow,
|
||||||
|
|
|
@ -253,6 +253,8 @@ impl Handle {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ffi::mpv_event_id_MPV_EVENT_SEEK => Some(MpvEvent::Seek),
|
||||||
|
|
||||||
11 => Some(MpvEvent::Unknown(event.event_id)),
|
11 => Some(MpvEvent::Unknown(event.event_id)),
|
||||||
|
|
||||||
_ => todo!("event {}", event.event_id),
|
_ => todo!("event {}", event.event_id),
|
||||||
|
|
|
@ -79,58 +79,42 @@ mod imp {
|
||||||
fn on_play_position_seek(
|
fn on_play_position_seek(
|
||||||
&self,
|
&self,
|
||||||
_scroll_type: gtk::ScrollType,
|
_scroll_type: gtk::ScrollType,
|
||||||
_value: f64,
|
value: f64,
|
||||||
_range: >k::Range,
|
_range: >k::Range,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
/*
|
self.window().seek(value);
|
||||||
let playbin = self.playbin.upgrade().unwrap();
|
false
|
||||||
if range.adjustment().lower() < range.adjustment().upper() {
|
|
||||||
playbin.seek(value);
|
|
||||||
}
|
|
||||||
false*/
|
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
fn on_skip_forward_clicked(&self) {
|
fn on_skip_forward_clicked(&self) {
|
||||||
/*
|
self.window().playlist_next();
|
||||||
let playbin = self.playbin.upgrade().unwrap();
|
|
||||||
playbin.go_to_next_track();*/
|
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
fn on_skip_backward_clicked(&self) {
|
fn on_skip_backward_clicked(&self) {
|
||||||
/*
|
self.window().playlist_prev();
|
||||||
let playbin = self.playbin.upgrade().unwrap();
|
|
||||||
playbin.go_to_prev_track();*/
|
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
fn seek_backward(&self) {
|
fn seek_backward(&self) {
|
||||||
/*
|
|
||||||
let playbin = self.playbin.upgrade().unwrap();
|
|
||||||
// 10 seconds
|
// 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 {
|
if new_position < 0.0 {
|
||||||
new_position = 0.0;
|
new_position = 0.0;
|
||||||
}
|
}
|
||||||
playbin.seek(new_position);*/
|
self.window().seek(new_position);
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
fn seek_forward(&self) {
|
fn seek_forward(&self) {
|
||||||
/*
|
|
||||||
let playbin = self.playbin.upgrade().unwrap();
|
|
||||||
// 10 seconds
|
// 10 seconds
|
||||||
let mut new_position = playbin.position() + 10.0;
|
let new_position = self.window().time_pos() + 10.0;
|
||||||
if new_position > playbin.duration() {
|
if new_position > self.window().duration() {
|
||||||
new_position = playbin.duration();
|
// just seek to the next track
|
||||||
|
self.on_skip_forward_clicked();
|
||||||
}
|
}
|
||||||
playbin.seek(new_position);*/
|
self.window().seek(new_position);
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
|
|
|
@ -403,10 +403,15 @@ mod imp {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
assert_eq!(
|
match self.mpv.get_property::<String>("path") {
|
||||||
song.stream_url(),
|
Ok(path) => assert_eq!(song.stream_url(), path),
|
||||||
self.mpv.get_property::<String>("path").unwrap()
|
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)
|
Some(song)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,4 +468,19 @@ impl Window {
|
||||||
self.imp().api.replace(Some(Rc::new(api)));
|
self.imp().api.replace(Some(Rc::new(api)));
|
||||||
self.set_can_click_shuffle_all(true);
|
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