mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +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:
parent
5925d3b26b
commit
87aed17a46
4 changed files with 23 additions and 31 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue