/src/serenity/Userland/Libraries/LibWeb/HTML/AudioTrack.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/String.h> |
10 | | #include <AK/Time.h> |
11 | | #include <LibAudio/Forward.h> |
12 | | #include <LibWeb/Bindings/PlatformObject.h> |
13 | | |
14 | | namespace Web::HTML { |
15 | | |
16 | | class AudioTrack final : public Bindings::PlatformObject { |
17 | | WEB_PLATFORM_OBJECT(AudioTrack, Bindings::PlatformObject); |
18 | | JS_DECLARE_ALLOCATOR(AudioTrack); |
19 | | |
20 | | public: |
21 | | virtual ~AudioTrack() override; |
22 | | |
23 | 0 | void set_audio_track_list(Badge<AudioTrackList>, JS::GCPtr<AudioTrackList> audio_track_list) { m_audio_track_list = audio_track_list; } |
24 | | |
25 | | void play(Badge<HTMLAudioElement>); |
26 | | void pause(Badge<HTMLAudioElement>); |
27 | | |
28 | | AK::Duration duration(); |
29 | | void seek(double, MediaSeekMode); |
30 | | |
31 | | void update_volume(); |
32 | | |
33 | 0 | String const& id() const { return m_id; } |
34 | 0 | String const& kind() const { return m_kind; } |
35 | 0 | String const& label() const { return m_label; } |
36 | 0 | String const& language() const { return m_language; } |
37 | | |
38 | 0 | bool enabled() const { return m_enabled; } |
39 | | void set_enabled(bool enabled); |
40 | | |
41 | | private: |
42 | | AudioTrack(JS::Realm&, JS::NonnullGCPtr<HTMLMediaElement>, NonnullRefPtr<Audio::Loader>); |
43 | | |
44 | | virtual void initialize(JS::Realm&) override; |
45 | | virtual void visit_edges(Cell::Visitor&) override; |
46 | | |
47 | | // https://html.spec.whatwg.org/multipage/media.html#dom-audiotrack-id |
48 | | String m_id; |
49 | | |
50 | | // https://html.spec.whatwg.org/multipage/media.html#dom-audiotrack-kind |
51 | | String m_kind; |
52 | | |
53 | | // https://html.spec.whatwg.org/multipage/media.html#dom-audiotrack-label |
54 | | String m_label; |
55 | | |
56 | | // https://html.spec.whatwg.org/multipage/media.html#dom-audiotrack-language |
57 | | String m_language; |
58 | | |
59 | | // https://html.spec.whatwg.org/multipage/media.html#dom-audiotrack-enabled |
60 | | bool m_enabled { false }; |
61 | | |
62 | | JS::NonnullGCPtr<HTMLMediaElement> m_media_element; |
63 | | JS::GCPtr<AudioTrackList> m_audio_track_list; |
64 | | |
65 | | NonnullOwnPtr<Platform::AudioCodecPlugin> m_audio_plugin; |
66 | | }; |
67 | | |
68 | | } |