mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
LibWeb: Update the duration of an element based on media data
This commit is contained in:
committed by
Gregory Bertilson
parent
d3374655cc
commit
d0d10b4200
Notes:
github-actions[bot]
2025-12-10 22:05:19 +00:00
Author: https://github.com/Zaggy1024 Commit: https://github.com/LadybirdBrowser/ladybird/commit/d0d10b42009 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6945 Reviewed-by: https://github.com/gmta Reviewed-by: https://github.com/kalenikaliaksandr ✅
@@ -1302,6 +1302,13 @@ void HTMLMediaElement::on_metadata_parsed()
|
||||
// FIXME: Handle unbounded media resources.
|
||||
set_duration(m_playback_manager->duration().to_seconds_f64());
|
||||
|
||||
// NB: Register the duration change handler here so that we don't set the duration when the
|
||||
// playback manager updates the duration after parsing.
|
||||
m_playback_manager->on_duration_change = [weak_self = GC::Weak(*this)](AK::Duration duration) {
|
||||
if (weak_self)
|
||||
weak_self->set_duration(duration.to_seconds_f64());
|
||||
};
|
||||
|
||||
// 5. For video elements, set the videoWidth and videoHeight attributes, and queue a media element task given the media element to fire an event
|
||||
// named resize at the media element.
|
||||
auto* video_element = as_if<HTMLVideoElement>(*this);
|
||||
|
||||
Reference in New Issue
Block a user