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

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: 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
Index: Source/core/html/HTMLMediaElement.cpp
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index 55fe318b23eea679d5f2c41fd8234f17eb74664d..ea4113d068cd8584f5c16240c5bfd92e5ecc7c68 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -2924,6 +2924,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);
@@ -2979,7 +2998,7 @@ void HTMLMediaElement::configureTextTracks()
if (chapterTracks.tracks.size())
configureTextTrackGroup(chapterTracks);
if (metadataTracks.tracks.size())
- configureTextTrackGroup(metadataTracks);
+ configureMetadataTextTrackGroup(metadataTracks);
if (otherTracks.tracks.size())
configureTextTrackGroup(otherTracks);
philipj_slow 2015/01/29 10:34:52 This looks like it's not per spec if you want to r
fs 2015/01/29 12:05:51 Yes, I noticed this as well, and I wondered what t
« LayoutTests/media/track/track-selection-metadata.html ('K') | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698