ladybird/Libraries/LibWeb/HTML/AudioTrack.h
Zaggy1024 3d0b8cc30c 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.
2025-10-27 17:28:49 -07:00

41 lines
1.1 KiB
C++

/*
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
* Copyright (c) 2025, Gregory Bertilson <gregory@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibMedia/Audio/Forward.h>
#include <LibMedia/Track.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/HTML/MediaTrackBase.h>
namespace Web::HTML {
class AudioTrack final : public MediaTrackBase {
WEB_PLATFORM_OBJECT(AudioTrack, MediaTrackBase);
GC_DECLARE_ALLOCATOR(AudioTrack);
public:
virtual ~AudioTrack() override;
void set_audio_track_list(Badge<AudioTrackList>, GC::Ptr<AudioTrackList> audio_track_list) { m_audio_track_list = audio_track_list; }
bool enabled() const { return m_enabled; }
void set_enabled(bool enabled);
private:
AudioTrack(JS::Realm&, GC::Ref<HTMLMediaElement>, Media::Track const&);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
// https://html.spec.whatwg.org/multipage/media.html#dom-audiotrack-enabled
bool m_enabled { false };
GC::Ptr<AudioTrackList> m_audio_track_list;
};
}