1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-02 20:32:12 +00:00

LibWeb: Implement HTMLMediaElement's duration attribute

This commit is contained in:
Timothy Flynn 2023-04-04 15:12:40 -04:00 committed by Linus Groh
parent 5f9fc5aedc
commit e10e041882
3 changed files with 49 additions and 8 deletions

View file

@ -11,6 +11,7 @@
#include <LibJS/SafeFunction.h>
#include <LibWeb/HTML/EventLoop/Task.h>
#include <LibWeb/HTML/HTMLElement.h>
#include <math.h>
namespace Web::HTML {
@ -33,6 +34,7 @@ public:
WebIDL::ExceptionOr<Bindings::CanPlayTypeResult> can_play_type(DeprecatedString const& type) const;
void load() const;
double duration() const;
void pause() const;
JS::NonnullGCPtr<VideoTrackList> video_tracks() const { return *m_video_tracks; }
@ -58,6 +60,7 @@ private:
WebIDL::ExceptionOr<void> process_media_data(Function<void()> failure_callback);
WebIDL::ExceptionOr<void> handle_media_source_failure();
void forget_media_resource_specific_tracks();
void set_duration(double);
// https://html.spec.whatwg.org/multipage/media.html#media-element-event-task-source
UniqueTaskSource m_media_element_event_task_source {};
@ -65,6 +68,9 @@ private:
// https://html.spec.whatwg.org/multipage/media.html#dom-media-networkstate
NetworkState m_network_state { NetworkState::Empty };
// https://html.spec.whatwg.org/multipage/media.html#dom-media-duration
double m_duration { NAN };
// https://html.spec.whatwg.org/multipage/media.html#dom-media-videotracks
JS::GCPtr<VideoTrackList> m_video_tracks;