summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZaggy1024 <zaggy1024@gmail.com>2023-02-05 19:40:52 -0600
committerSam Atkins <atkinssj@gmail.com>2023-02-07 14:36:58 +0000
commit9e61e48b318d53f85865b5206f4bb0e545f00990 (patch)
tree1234885316d1f48f6204598a2fd6c60552e80749
parentd9a73bbc96745263ac33134b5f9341fd0006255c (diff)
downloadserenity-9e61e48b318d53f85865b5206f4bb0e545f00990.zip
VideoPlayer: Pause while the user is dragging the seek bar
-rw-r--r--Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp18
-rw-r--r--Userland/Applications/VideoPlayer/VideoPlayerWidget.h2
2 files changed, 17 insertions, 3 deletions
diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp
index ddc6040c82..61d15e69fe 100644
--- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp
+++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp
@@ -37,6 +37,18 @@ ErrorOr<void> VideoPlayerWidget::setup_interface()
m_video_display->on_click = [&]() { toggle_pause(); };
m_seek_slider = find_descendant_of_type_named<GUI::HorizontalSlider>("seek_slider");
+ m_seek_slider->on_drag_start = [&]() {
+ if (!m_playback_manager)
+ return;
+ m_was_playing_before_seek = m_playback_manager->is_playing();
+ m_playback_manager->pause_playback();
+ };
+ m_seek_slider->on_drag_end = [&]() {
+ if (!m_playback_manager || !m_was_playing_before_seek)
+ return;
+ m_was_playing_before_seek = false;
+ m_playback_manager->resume_playback();
+ };
m_seek_slider->on_change = [&](int value) {
if (!m_playback_manager)
return;
@@ -103,7 +115,7 @@ void VideoPlayerWidget::update_play_pause_icon()
m_play_pause_action->set_enabled(true);
- if (m_playback_manager->is_playing()) {
+ if (m_playback_manager->is_playing() || m_was_playing_before_seek) {
m_play_pause_action->set_icon(m_pause_icon);
m_play_pause_action->set_text("Pause"sv);
} else {
@@ -114,7 +126,7 @@ void VideoPlayerWidget::update_play_pause_icon()
void VideoPlayerWidget::resume_playback()
{
- if (!m_playback_manager)
+ if (!m_playback_manager || m_seek_slider->knob_dragging())
return;
m_playback_manager->resume_playback();
update_play_pause_icon();
@@ -122,7 +134,7 @@ void VideoPlayerWidget::resume_playback()
void VideoPlayerWidget::pause_playback()
{
- if (!m_playback_manager)
+ if (!m_playback_manager || m_seek_slider->knob_dragging())
return;
m_playback_manager->pause_playback();
update_play_pause_icon();
diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.h b/Userland/Applications/VideoPlayer/VideoPlayerWidget.h
index 61760387bf..bdc53cb630 100644
--- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.h
+++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.h
@@ -68,6 +68,8 @@ private:
RefPtr<GUI::Action> m_use_fast_seeking;
OwnPtr<Video::PlaybackManager> m_playback_manager;
+
+ bool m_was_playing_before_seek { false };
};
}