diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-04-04 09:26:02 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-04-07 16:02:22 +0200 |
commit | 3f1badf9b20ee9ffbb95159c327e354bad6cf986 (patch) | |
tree | 3a985507792411c1954551331430bfc668310eed /Userland/Libraries/LibWeb/HTML/VideoTrackList.h | |
parent | 9f8da9798a60f897d0afe4f2263a736d133a6547 (diff) | |
download | serenity-3f1badf9b20ee9ffbb95159c327e354bad6cf986.zip |
LibWeb: Implement VideoTrack and VideoTrackList
This implements the IDL for these types and some event handling around
them.
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/VideoTrackList.h')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/VideoTrackList.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/VideoTrackList.h b/Userland/Libraries/LibWeb/HTML/VideoTrackList.h new file mode 100644 index 0000000000..d0f9732d12 --- /dev/null +++ b/Userland/Libraries/LibWeb/HTML/VideoTrackList.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <AK/Badge.h> +#include <AK/String.h> +#include <LibJS/Heap/MarkedVector.h> +#include <LibWeb/DOM/EventTarget.h> +#include <LibWeb/HTML/VideoTrack.h> + +namespace Web::HTML { + +class VideoTrackList final : public DOM::EventTarget { + WEB_PLATFORM_OBJECT(VideoTrackList, DOM::EventTarget); + +public: + ErrorOr<void> add_track(Badge<HTMLMediaElement>, JS::NonnullGCPtr<VideoTrack>); + void remove_all_tracks(Badge<HTMLMediaElement>); + + Span<JS::NonnullGCPtr<VideoTrack>> video_tracks(Badge<VideoTrack>) { return m_video_tracks; } + + // https://html.spec.whatwg.org/multipage/media.html#dom-videotracklist-length + size_t length() const { return m_video_tracks.size(); } + + JS::GCPtr<VideoTrack> get_track_by_id(StringView id) const; + i32 selected_index() const; + + void set_onchange(WebIDL::CallbackType*); + WebIDL::CallbackType* onchange(); + + void set_onaddtrack(WebIDL::CallbackType*); + WebIDL::CallbackType* onaddtrack(); + + void set_onremovetrack(WebIDL::CallbackType*); + WebIDL::CallbackType* onremovetrack(); + +private: + explicit VideoTrackList(JS::Realm&); + + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> internal_get_own_property(JS::PropertyKey const& property_name) const override; + + JS::MarkedVector<JS::NonnullGCPtr<VideoTrack>> m_video_tracks; +}; + +} |