mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
LibWeb: Set AudioTrack and VideoTrack fields according to spec
The two classes now inherit from a common base MediaTrackBase, to deduplicate the attributes that are shared between the two. The integer ID from the container is used for each track's id attribute. The kind attribute is set to "main" or "translation" according to: https://dev.w3.org/html5/html-sourcing-inband-tracks/ The label attribute is set to the human-readable name of the track, if one is present. The language attribute is set to a BCP 47 language tag, if one can be parsed successfully.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
29ab9c5fd5
commit
3d0b8cc30c
Notes:
github-actions[bot]
2025-10-28 00:34:44 +00:00
Author: https://github.com/Zaggy1024 Commit: https://github.com/LadybirdBrowser/ladybird/commit/3d0b8cc30c9 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6410 Reviewed-by: https://github.com/R-Goc Reviewed-by: https://github.com/gmta ✅
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2025, Gregory Bertilson <gregory@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
@@ -10,11 +11,12 @@
|
||||
#include <AK/Time.h>
|
||||
#include <LibMedia/Track.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/HTML/MediaTrackBase.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
class VideoTrack final : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(VideoTrack, Bindings::PlatformObject);
|
||||
class VideoTrack final : public MediaTrackBase {
|
||||
WEB_PLATFORM_OBJECT(VideoTrack, MediaTrackBase);
|
||||
GC_DECLARE_ALLOCATOR(VideoTrack);
|
||||
|
||||
public:
|
||||
@@ -22,41 +24,19 @@ public:
|
||||
|
||||
void set_video_track_list(Badge<VideoTrackList>, GC::Ptr<VideoTrackList> video_track_list) { m_video_track_list = video_track_list; }
|
||||
|
||||
String const& id() const { return m_id; }
|
||||
String const& kind() const { return m_kind; }
|
||||
String const& label() const { return m_label; }
|
||||
String const& language() const { return m_language; }
|
||||
|
||||
bool selected() const { return m_selected; }
|
||||
void set_selected(bool selected);
|
||||
|
||||
Media::Track const& track_in_playback_manager() const { return m_track_in_playback_manager; }
|
||||
|
||||
private:
|
||||
VideoTrack(JS::Realm&, GC::Ref<HTMLMediaElement>, Media::Track const& track);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#dom-videotrack-id
|
||||
String m_id;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#dom-videotrack-kind
|
||||
String m_kind;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#dom-videotrack-label
|
||||
String m_label;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#dom-videotrack-language
|
||||
String m_language;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/media.html#dom-videotrack-selected
|
||||
bool m_selected { false };
|
||||
|
||||
GC::Ref<HTMLMediaElement> m_media_element;
|
||||
GC::Ptr<VideoTrackList> m_video_track_list;
|
||||
|
||||
Media::Track m_track_in_playback_manager;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user