Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1013)

Unified Diff: Source/core/html/HTMLMediaElement.cpp

Issue 882993002: Implement automatic text track selection for 'metadata' tracks (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Test touch-up. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLMediaElement.cpp
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index 06c08ee0420b0fea033c59a1905fb7e82508521f..f19c5656a98b37733535c6a54fd4d651303f4061 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -2921,6 +2921,25 @@ void HTMLMediaElement::configureTextTrackGroup(const TrackGroup& group)
trackToEnable->setMode(TextTrack::showingKeyword());
}
+void HTMLMediaElement::configureMetadataTextTrackGroup(const TrackGroup& group)
+{
+ ASSERT(group.tracks.size());
+
+ // https://html.spec.whatwg.org/multipage/embedded-content.html#honor-user-preferences-for-automatic-text-track-selection
+
+ // 4. If there are any text tracks in the media element's list of text
+ // tracks whose text track kind is metadata that correspond to track
+ // elements with a default attribute set whose text track mode is set to
+ // disabled, then set the text track mode of all such tracks to hidden
+ for (auto& textTrack : group.tracks) {
+ if (textTrack->mode() != TextTrack::disabledKeyword())
+ continue;
+ if (!textTrack->isDefault())
+ continue;
+ textTrack->setMode(TextTrack::hiddenKeyword());
+ }
+}
+
void HTMLMediaElement::configureTextTracks()
{
TrackGroup captionAndSubtitleTracks(TrackGroup::CaptionsAndSubtitles);
@@ -2976,7 +2995,7 @@ void HTMLMediaElement::configureTextTracks()
if (chapterTracks.tracks.size())
configureTextTrackGroup(chapterTracks);
if (metadataTracks.tracks.size())
- configureTextTrackGroup(metadataTracks);
+ configureMetadataTextTrackGroup(metadataTracks);
if (otherTracks.tracks.size())
configureTextTrackGroup(otherTracks);
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698