1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +00:00

LibWeb: Begin tracking HTMLMediaElement playback positions

There are several playback positions to be tracked, depending on the
state of the media element.
This commit is contained in:
Timothy Flynn 2023-04-10 10:07:23 -04:00 committed by Linus Groh
parent 6b51c3c1ce
commit 3d9106b1b5
5 changed files with 195 additions and 9 deletions

View file

@ -47,6 +47,11 @@ public:
ReadyState ready_state() const { return m_ready_state; }
WebIDL::ExceptionOr<void> load();
double current_time() const;
void set_current_time(double);
void set_current_playback_position(double);
double duration() const;
bool paused() const { return m_paused; }
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> play();
@ -90,6 +95,12 @@ private:
WebIDL::ExceptionOr<void> dispatch_time_update_event();
enum class TimeMarchesOnReason {
NormalPlayback,
Other,
};
void time_marches_on(TimeMarchesOnReason = TimeMarchesOnReason::NormalPlayback);
JS::MarkedVector<JS::NonnullGCPtr<WebIDL::Promise>> take_pending_play_promises();
void resolve_pending_play_promises(ReadonlySpan<JS::NonnullGCPtr<WebIDL::Promise>> promises);
void reject_pending_play_promises(ReadonlySpan<JS::NonnullGCPtr<WebIDL::Promise>> promises, JS::NonnullGCPtr<WebIDL::DOMException> error);
@ -114,6 +125,15 @@ private:
ReadyState m_ready_state { ReadyState::HaveNothing };
bool m_first_data_load_event_since_load_start { false };
// https://html.spec.whatwg.org/multipage/media.html#current-playback-position
double m_current_playback_position { 0 };
// https://html.spec.whatwg.org/multipage/media.html#official-playback-position
double m_official_playback_position { 0 };
// https://html.spec.whatwg.org/multipage/media.html#default-playback-start-position
double m_default_playback_start_position { 0 };
// https://html.spec.whatwg.org/multipage/media.html#dom-media-duration
double m_duration { NAN };