summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/VideoTrackList.h
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-04-04 09:26:02 -0400
committerLinus Groh <mail@linusgroh.de>2023-04-07 16:02:22 +0200
commit3f1badf9b20ee9ffbb95159c327e354bad6cf986 (patch)
tree3a985507792411c1954551331430bfc668310eed /Userland/Libraries/LibWeb/HTML/VideoTrackList.h
parent9f8da9798a60f897d0afe4f2263a736d133a6547 (diff)
downloadserenity-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.h50
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;
+};
+
+}