diff options
author | Zaggy1024 <zaggy1024@gmail.com> | 2023-02-12 02:25:25 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-12 18:47:56 +0100 |
commit | a6b938b40767e3e975064641e850562b22f917fd (patch) | |
tree | 02536883221bd09bea1a61e0632e6653c9385ffb /Userland | |
parent | aa0f7d9c899dee40557b2676321c087657199c2c (diff) | |
download | serenity-a6b938b40767e3e975064641e850562b22f917fd.zip |
LibVideo/VideoPlayer: Dispatch state change events and update play icon
The PlaybackStateChangeEvent wasn't connected up anymore, so the player
wouldn't change icons when stopping playback due to reaching the end of
the stream or encountering an error.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/PlaybackManager.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibVideo/PlaybackManager.h | 1 |
3 files changed, 7 insertions, 2 deletions
diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp index 8541e631ec..57e7ffe51d 100644 --- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp +++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp @@ -129,7 +129,6 @@ void VideoPlayerWidget::resume_playback() if (!m_playback_manager || m_seek_slider->knob_dragging()) return; m_playback_manager->resume_playback(); - update_play_pause_icon(); } void VideoPlayerWidget::pause_playback() @@ -137,7 +136,6 @@ void VideoPlayerWidget::pause_playback() if (!m_playback_manager || m_seek_slider->knob_dragging()) return; m_playback_manager->pause_playback(); - update_play_pause_icon(); } void VideoPlayerWidget::toggle_pause() diff --git a/Userland/Libraries/LibVideo/PlaybackManager.cpp b/Userland/Libraries/LibVideo/PlaybackManager.cpp index a2c6dc19b4..92c293c932 100644 --- a/Userland/Libraries/LibVideo/PlaybackManager.cpp +++ b/Userland/Libraries/LibVideo/PlaybackManager.cpp @@ -121,6 +121,11 @@ bool PlaybackManager::dispatch_frame_queue_item(FrameQueueItem&& item) return false; } +void PlaybackManager::dispatch_state_change() +{ + m_main_loop.post_event(m_event_handler, TRY_OR_FATAL_ERROR(try_make<PlaybackStateChangeEvent>())); +} + void PlaybackManager::timer_callback() { TRY_OR_FATAL_ERROR(m_playback_handler->on_timer_callback()); @@ -265,6 +270,7 @@ ErrorOr<void> PlaybackManager::PlaybackStateHandler::replace_handler_and_delete_ m_has_exited = true; dbgln("Changing state from {} to {}", temp_handler->name(), m_manager.m_playback_handler->name()); #endif + m_manager.dispatch_state_change(); TRY(m_manager.m_playback_handler->on_enter()); return {}; } diff --git a/Userland/Libraries/LibVideo/PlaybackManager.h b/Userland/Libraries/LibVideo/PlaybackManager.h index f71cfbb726..311dafa380 100644 --- a/Userland/Libraries/LibVideo/PlaybackManager.h +++ b/Userland/Libraries/LibVideo/PlaybackManager.h @@ -132,6 +132,7 @@ private: void dispatch_new_frame(RefPtr<Gfx::Bitmap> frame); // Returns whether we changed playback states. If so, any PlaybackStateHandler processing must cease. [[nodiscard]] bool dispatch_frame_queue_item(FrameQueueItem&&); + void dispatch_state_change(); void dispatch_fatal_error(Error); Core::Object& m_event_handler; |