Browse files

fix: default subtitles not enabled (#5608)

This is a follow-up to this fix in VHS, after which default in-manifest subtitles were still not being correctly enabled. The reason is because Video.js's text track preselection logic was running before the media groups were set up in VHS.

Text track preselection should happen on `loadedmetadata` instead of `loadstart`. According to the HTML spec, text track data is available on `loadedmetadata`, so we should be waiting until then to make preselection decisions.
  • Loading branch information...
alex-barstow authored and gkatsev committed Nov 29, 2018
1 parent 6c1056b commit 8329e64e6fe74c8892673cc53f6766ea52003b36
Showing with 2 additions and 2 deletions.
  1. +1 −1 src/js/tracks/text-track-display.js
  2. +1 −1 test/unit/tracks/text-track-display.test.js
@@ -102,7 +102,7 @@ class TextTrackDisplay extends Component {

player.on('loadstart', Fn.bind(this, this.toggleDisplay));
player.on('texttrackchange', updateDisplayHandler);
player.on('loadstart', Fn.bind(this, this.preselectTrack));
player.on('loadedmetadata', Fn.bind(this, this.preselectTrack));

// This used to be called during player init, but was causing an error
// if a track should show by default and the display hadn't loaded yet.
@@ -218,7 +218,7 @@ if (!Html5.supportsNativeTextTracks()) {

// Force es as "user-selected" track
player.cache_.selectedLanguage = { enabled: true, language: 'es', kind: 'captions' };

assert.equal(spanishTrack.mode, 'showing', 'Spanish captions should be showing');
assert.equal(englishTrack.mode, 'disabled', 'English captions should be disabled');

0 comments on commit 8329e64

Please sign in to comment.