mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
VideoPlayer: Make PlaybackManager use OwnPtr
VideoPlayerWidget was keeping a reference to PlaybackManager when changing files, so the old and new managers would both send frames to be presented at the same time, causing it to flicker back and forth between the two videos. However, PlaybackManager no longer relies on event bubbling to pass events to its parent. By changing it to send events directly to an Object, it can avoid being ref counted, so that it will get destroyed with its containing object and stop sending events.
This commit is contained in:
@@ -69,9 +69,15 @@ VideoPlayerWidget::VideoPlayerWidget(GUI::Window& window)
|
||||
m_volume_slider->set_fixed_width(100);
|
||||
}
|
||||
|
||||
void VideoPlayerWidget::close_file()
|
||||
{
|
||||
if (m_playback_manager)
|
||||
m_playback_manager = nullptr;
|
||||
}
|
||||
|
||||
void VideoPlayerWidget::open_file(StringView filename)
|
||||
{
|
||||
auto load_file_result = Video::PlaybackManager::from_file(this, filename);
|
||||
auto load_file_result = Video::PlaybackManager::from_file(*this, filename);
|
||||
|
||||
if (load_file_result.is_error()) {
|
||||
on_decoding_error(load_file_result.release_error());
|
||||
@@ -81,6 +87,7 @@ void VideoPlayerWidget::open_file(StringView filename)
|
||||
m_path = filename;
|
||||
update_title();
|
||||
|
||||
close_file();
|
||||
m_playback_manager = load_file_result.release_value();
|
||||
resume_playback();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user