LibWeb: Implement the HTMLMediaElement paused attribute

Note that the default value of the attribute is true. We were previously
autoplaying videos as soon as they loaded - this will prevent that from
happening until the paused attribute is set to false.
This commit is contained in:
Timothy Flynn 2023-04-07 11:10:57 -04:00 committed by Linus Groh
parent e130525c24
commit 90921a4f16
Notes: sideshowbarker 2024-07-17 00:16:31 +09:00
5 changed files with 68 additions and 7 deletions

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, the SerenityOS developers.
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -84,9 +85,10 @@ void HTMLVideoElement::set_video_track(JS::GCPtr<HTML::VideoTrack> video_track)
m_video_timer->stop();
m_video_track = video_track;
if (!m_video_track)
return;
}
void HTMLVideoElement::on_playing()
{
if (!m_video_timer) {
m_video_timer = Platform::Timer::create_repeating(s_frame_delay_ms, [this]() {
if (auto frame = m_video_track->next_frame())
@ -101,4 +103,10 @@ void HTMLVideoElement::set_video_track(JS::GCPtr<HTML::VideoTrack> video_track)
m_video_timer->start();
}
void HTMLVideoElement::on_paused()
{
if (m_video_timer)
m_video_timer->stop();
}
}