diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp index 1facab92a4..8541e631ec 100644 --- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp +++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp @@ -56,7 +56,8 @@ ErrorOr VideoPlayerWidget::setup_interface() auto progress = value / static_cast(m_seek_slider->max()); auto duration = m_playback_manager->duration().to_milliseconds(); Time timestamp = Time::from_milliseconds(static_cast(round(progress * static_cast(duration)))); - m_playback_manager->seek_to_timestamp(timestamp); + auto seek_mode_to_use = m_seek_slider->knob_dragging() ? seek_mode() : Video::PlaybackManager::SeekMode::Accurate; + m_playback_manager->seek_to_timestamp(timestamp, seek_mode_to_use); set_current_timestamp(m_playback_manager->current_playback_time()); }; @@ -100,7 +101,6 @@ void VideoPlayerWidget::open_file(StringView filename) close_file(); m_playback_manager = load_file_result.release_value(); update_seek_slider_max(); - update_seek_mode(); resume_playback(); } @@ -277,13 +277,6 @@ void VideoPlayerWidget::set_seek_mode(Video::PlaybackManager::SeekMode seek_mode m_use_fast_seeking->set_checked(seek_mode == Video::PlaybackManager::SeekMode::Fast); } -void VideoPlayerWidget::update_seek_mode() -{ - if (!m_playback_manager) - return; - m_playback_manager->set_seek_mode(seek_mode()); -} - ErrorOr VideoPlayerWidget::initialize_menubar(GUI::Window& window) { // File menu @@ -303,9 +296,7 @@ ErrorOr VideoPlayerWidget::initialize_menubar(GUI::Window& window) // FIXME: Maybe seek mode should be in an options dialog instead. The playback menu may get crowded. // For now, leave it here for convenience. - m_use_fast_seeking = GUI::Action::create_checkable("&Fast Seeking", [&](auto&) { - update_seek_mode(); - }); + m_use_fast_seeking = GUI::Action::create_checkable("&Fast Seeking", [&](auto&) {}); TRY(playback_menu->try_add_action(*m_use_fast_seeking)); set_seek_mode(Video::PlaybackManager::DEFAULT_SEEK_MODE); diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.h b/Userland/Applications/VideoPlayer/VideoPlayerWidget.h index bdc53cb630..a72590d95e 100644 --- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.h +++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.h @@ -46,7 +46,6 @@ private: void set_current_timestamp(Time); void set_time_label(Time); void on_decoding_error(Video::DecoderError const&); - void update_seek_mode(); void cycle_sizing_modes(); diff --git a/Userland/Libraries/LibVideo/PlaybackManager.cpp b/Userland/Libraries/LibVideo/PlaybackManager.cpp index 9a808402b8..5a49f32bd2 100644 --- a/Userland/Libraries/LibVideo/PlaybackManager.cpp +++ b/Userland/Libraries/LibVideo/PlaybackManager.cpp @@ -109,9 +109,9 @@ void PlaybackManager::timer_callback() TRY_OR_FATAL_ERROR(m_playback_handler->on_timer_callback()); } -void PlaybackManager::seek_to_timestamp(Time target_timestamp) +void PlaybackManager::seek_to_timestamp(Time target_timestamp, SeekMode seek_mode) { - TRY_OR_FATAL_ERROR(m_playback_handler->seek(target_timestamp, m_seek_mode)); + TRY_OR_FATAL_ERROR(m_playback_handler->seek(target_timestamp, seek_mode)); } Optional