diff --git a/src/window.blp b/src/window.blp index 24a33f0..02d8b1d 100644 --- a/src/window.blp +++ b/src/window.blp @@ -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 { diff --git a/src/window.vala b/src/window.vala index 12f6151..0c96ca3 100644 --- a/src/window.vala +++ b/src/window.vala @@ -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); + } }