1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-19 10:54:16 +02:00

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.
This commit is contained in:
Alex Barstow 2018-11-29 14:03:51 -05:00 committed by Gary Katsevman
parent 6c1056b665
commit 8329e64e6f
2 changed files with 2 additions and 2 deletions

View File

@ -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.

View File

@ -218,7 +218,7 @@ if (!Html5.supportsNativeTextTracks()) {
// Force es as "user-selected" track
player.cache_.selectedLanguage = { enabled: true, language: 'es', kind: 'captions' };
player.trigger('loadstart');
player.trigger('loadedmetadata');
assert.equal(spanishTrack.mode, 'showing', 'Spanish captions should be showing');
assert.equal(englishTrack.mode, 'disabled', 'English captions should be disabled');