From 3952ff47869ed535c78aed015f74cd201bc5238b Mon Sep 17 00:00:00 2001 From: Psychpsyo Date: Fri, 14 Feb 2025 11:22:01 +0100 Subject: [PATCH] LibWeb: Add a stub for HTMLMediaElement.played() --- Libraries/LibWeb/HTML/HTMLMediaElement.cpp | 12 ++++++++++++ Libraries/LibWeb/HTML/HTMLMediaElement.h | 1 + Libraries/LibWeb/HTML/HTMLMediaElement.idl | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index 99a6cbc03d2..b3b47201f51 100644 --- a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -173,6 +173,18 @@ GC::Ref HTMLMediaElement::buffered() const return realm.create(realm); } +// https://html.spec.whatwg.org/multipage/media.html#dom-media-played +GC::Ref HTMLMediaElement::played() const +{ + auto& realm = this->realm(); + + // The played attribute must return a new static normalized TimeRanges object that represents the ranges of points on the media timeline of the media resource reached through the + // usual monotonic increase of the current playback position during normal playback, if any, at the time the attribute is evaluated. + auto time_ranges = realm.create(realm); + // FIXME: Actually add the correct ranges + return time_ranges; +} + // https://html.spec.whatwg.org/multipage/media.html#dom-navigator-canplaytype Bindings::CanPlayTypeResult HTMLMediaElement::can_play_type(StringView type) const { diff --git a/Libraries/LibWeb/HTML/HTMLMediaElement.h b/Libraries/LibWeb/HTML/HTMLMediaElement.h index 9923331f585..e666d7b1c19 100644 --- a/Libraries/LibWeb/HTML/HTMLMediaElement.h +++ b/Libraries/LibWeb/HTML/HTMLMediaElement.h @@ -57,6 +57,7 @@ public: NetworkState network_state() const { return m_network_state; } [[nodiscard]] GC::Ref buffered() const; + [[nodiscard]] GC::Ref played() const; static inline constexpr auto supported_video_subtypes = Array { "webm"sv, diff --git a/Libraries/LibWeb/HTML/HTMLMediaElement.idl b/Libraries/LibWeb/HTML/HTMLMediaElement.idl index e4d58c251c3..22bc813886d 100644 --- a/Libraries/LibWeb/HTML/HTMLMediaElement.idl +++ b/Libraries/LibWeb/HTML/HTMLMediaElement.idl @@ -62,7 +62,7 @@ interface HTMLMediaElement : HTMLElement { attribute double defaultPlaybackRate; attribute double playbackRate; [FIXME] attribute boolean preservesPitch; - [FIXME] readonly attribute TimeRanges played; + readonly attribute TimeRanges played; [FIXME] readonly attribute TimeRanges seekable; readonly attribute boolean ended; [Reflect, CEReactions] attribute boolean autoplay;