partial seek button support

This commit is contained in:
Erica Z 2024-10-13 08:14:40 +00:00
parent 81b9acca6a
commit 94107f9e60
2 changed files with 20 additions and 0 deletions

View file

@ -171,6 +171,8 @@ paintable: bind template.playing_cover_art;
Button {
icon-name: "media-seek-backward";
valign: center;
clicked => $seek_backward ();
}
Button {
@ -183,6 +185,8 @@ paintable: bind template.playing_cover_art;
Button {
icon-name: "media-seek-forward";
valign: center;
clicked => $seek_forward ();
}
Button {

View file

@ -202,4 +202,20 @@ class Window : Adw.ApplicationWindow {
[GtkCallback] private string format_song_below_title (Song? song) {
return song == null ? "" : @"$(song.artist) - $(song.album) - $(song.year)";
}
[GtkCallback] private void seek_backward () {
// 10 seconds
int64 new_position = position - (int64)10 * 1000 * 1000000;
if (new_position < 0) new_position = 0;
this.position = new_position;
this.playbin.seek.begin (new_position);
}
[GtkCallback] private void seek_forward () {
// 10 seconds
int64 new_position = position + (int64)10 * 1000 * 1000000;
if (new_position > this.playbin.duration) new_position = this.playbin.duration;
this.position = new_position;
this.playbin.seek.begin (new_position);
}
}