From 907f7b9ea541205bbf57e3f732bfa681c0df5b8a Mon Sep 17 00:00:00 2001 From: me Date: Sun, 13 Oct 2024 08:14:40 +0000 Subject: [PATCH] partial seek button support --- src/window.blp | 4 ++++ src/window.vala | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) 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); + } }