/src/serenity/Userland/Libraries/LibWeb/HTML/VideoTrack.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 <LibGfx/Forward.h> |
12 | | #include <LibMedia/Forward.h> |
13 | | #include <LibWeb/Bindings/PlatformObject.h> |
14 | | |
15 | | namespace Web::HTML { |
16 | | |
17 | | class VideoTrack final : public Bindings::PlatformObject { |
18 | | WEB_PLATFORM_OBJECT(VideoTrack, Bindings::PlatformObject); |
19 | | JS_DECLARE_ALLOCATOR(VideoTrack); |
20 | | |
21 | | public: |
22 | | virtual ~VideoTrack() override; |
23 | | |
24 | 0 | void set_video_track_list(Badge<VideoTrackList>, JS::GCPtr<VideoTrackList> video_track_list) { m_video_track_list = video_track_list; } |
25 | | |
26 | | void play_video(Badge<HTMLVideoElement>); |
27 | | void pause_video(Badge<HTMLVideoElement>); |
28 | | void stop_video(Badge<HTMLVideoElement>); |
29 | | |
30 | | AK::Duration position() const; |
31 | | AK::Duration duration() const; |
32 | | void seek(AK::Duration, MediaSeekMode); |
33 | | |
34 | | u64 pixel_width() const; |
35 | | u64 pixel_height() const; |
36 | | |
37 | 0 | String const& id() const { return m_id; } |
38 | 0 | String const& kind() const { return m_kind; } |
39 | 0 | String const& label() const { return m_label; } |
40 | 0 | String const& language() const { return m_language; } |
41 | | |
42 | 0 | bool selected() const { return m_selected; } |
43 | | void set_selected(bool selected); |
44 | | |
45 | | private: |
46 | | VideoTrack(JS::Realm&, JS::NonnullGCPtr<HTMLMediaElement>, NonnullOwnPtr<Media::PlaybackManager>); |
47 | | |
48 | | virtual void initialize(JS::Realm&) override; |
49 | | virtual void visit_edges(Cell::Visitor&) override; |
50 | | |
51 | | // https://html.spec.whatwg.org/multipage/media.html#dom-videotrack-id |
52 | | String m_id; |
53 | | |
54 | | // https://html.spec.whatwg.org/multipage/media.html#dom-videotrack-kind |
55 | | String m_kind; |
56 | | |
57 | | // https://html.spec.whatwg.org/multipage/media.html#dom-videotrack-label |
58 | | String m_label; |
59 | | |
60 | | // https://html.spec.whatwg.org/multipage/media.html#dom-videotrack-language |
61 | | String m_language; |
62 | | |
63 | | // https://html.spec.whatwg.org/multipage/media.html#dom-videotrack-selected |
64 | | bool m_selected { false }; |
65 | | |
66 | | JS::NonnullGCPtr<HTMLMediaElement> m_media_element; |
67 | | JS::GCPtr<VideoTrackList> m_video_track_list; |
68 | | |
69 | | NonnullOwnPtr<Media::PlaybackManager> m_playback_manager; |
70 | | }; |
71 | | |
72 | | } |