From d8b9773210895f36f32e6b417ec3259483b50884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sun, 7 Apr 2024 20:47:03 +0200 Subject: [PATCH] clapper-gtk: Pause video when dragging Before we can do actual scrubbing, we need to pause playback and do seeks while it is paused. Then restore playing state after dragging ends. --- src/lib/clapper-gtk/clapper-gtk-seek-bar.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib/clapper-gtk/clapper-gtk-seek-bar.c b/src/lib/clapper-gtk/clapper-gtk-seek-bar.c index 6afdbf99..f6de3783 100644 --- a/src/lib/clapper-gtk/clapper-gtk-seek-bar.c +++ b/src/lib/clapper-gtk/clapper-gtk-seek-bar.c @@ -57,6 +57,7 @@ struct _ClapperGtkSeekBar gboolean can_scrub; gboolean scrubbing; + gboolean was_playing; gboolean dragging; guint position_uint; @@ -267,6 +268,14 @@ scale_css_classes_changed_cb (GtkWidget *widget, if ((self->dragging = dragging)) { GST_DEBUG_OBJECT (self, "Scale drag started"); + + if (G_LIKELY (self->player != NULL)) { + ClapperPlayerState state = clapper_player_get_state (self->player); + + if ((self->was_playing = (state == CLAPPER_PLAYER_STATE_PLAYING))) + clapper_player_pause (self->player); + } + return; } @@ -289,6 +298,9 @@ scale_css_classes_changed_cb (GtkWidget *widget, } else { clapper_player_seek_custom (self->player, value, self->seek_method); } + + if (self->was_playing) + clapper_player_play (self->player); } static void