LibWeb: Implement TimeRanges and HTMLMediaElement.seekable()

This commit is contained in:
Psychpsyo 2025-02-14 11:22:12 +01:00 committed by Andrew Kaster
parent 3952ff4786
commit aa243000f3
Notes: github-actions[bot] 2025-02-18 17:46:30 +00:00
5 changed files with 103 additions and 18 deletions

View file

@ -8,22 +8,39 @@
#include <LibJS/Forward.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/media.html#time-ranges
class TimeRanges final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(TimeRanges, Bindings::PlatformObject);
GC_DECLARE_ALLOCATOR(TimeRanges);
public:
// https://html.spec.whatwg.org/multipage/media.html#dom-timeranges-length
size_t length() const;
double start(u32 index) const;
double end(u32 index) const;
// https://html.spec.whatwg.org/multipage/media.html#dom-timeranges-start
WebIDL::ExceptionOr<double> start(u32 index) const;
// https://html.spec.whatwg.org/multipage/media.html#dom-timeranges-end
WebIDL::ExceptionOr<double> end(u32 index) const;
void add_range(double start, double end);
bool in_range(double);
private:
explicit TimeRanges(JS::Realm&);
virtual void initialize(JS::Realm&) override;
struct Range {
double start;
double end;
};
Vector<Range> m_ranges;
};
}