mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +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 ✅
@@ -1237,6 +1237,18 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void(Str
|
||||
if (enable == TriState::True)
|
||||
audio_track->set_enabled(true);
|
||||
|
||||
// AD-HOC(ish): According to https://dev.w3.org/html5/html-sourcing-inband-tracks/, kind should be set according to format, and the following criteria within
|
||||
// the specified formats.
|
||||
// WebM:
|
||||
// - "main": the FlagDefault element is set on the track
|
||||
// - "translation": not first audio (video) track
|
||||
// MP4:
|
||||
// - "main": first audio (video) track
|
||||
// - "translation": not first audio (video) track
|
||||
// Though the behavior for WebM is not clear if its first track is not marked with FlagDefault, the idea here seems to be that the preferred
|
||||
// track should be marked as "main", and the rest should be marked as "translation".
|
||||
audio_track->set_kind(enable == TriState::True ? "main"_utf16 : "translation"_utf16);
|
||||
|
||||
// 7. Fire an event named addtrack at this AudioTrackList object, using TrackEvent, with the track attribute initialized to the new AudioTrack object.
|
||||
TrackEventInit event_init {};
|
||||
event_init.track = GC::make_root(audio_track);
|
||||
@@ -1284,6 +1296,9 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void(Str
|
||||
if (enable == TriState::True)
|
||||
video_track->set_selected(true);
|
||||
|
||||
// AD-HOC(ish): See the comment regarding AudioTrack.kind above with regard to https://dev.w3.org/html5/html-sourcing-inband-tracks/.
|
||||
video_track->set_kind(enable == TriState::True ? "main"_utf16 : "translation"_utf16);
|
||||
|
||||
// 7. Fire an event named addtrack at this VideoTrackList object, using TrackEvent, with the track attribute initialized to the new VideoTrack object.
|
||||
TrackEventInit event_init {};
|
||||
event_init.track = GC::make_root(video_track);
|
||||
|
||||
Reference in New Issue
Block a user