diff options
author | Sam Potts <sam@potts.es> | 2020-04-23 22:03:45 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-23 22:03:45 +1000 |
commit | dbe618c644a525b196466b7254274cc9bde76275 (patch) | |
tree | bfd3bd24ce9cdedb33b39d881f66417ac0b80f04 /src | |
parent | 6f1366bd198e52ea17ead09c0e593572c2f846db (diff) | |
parent | 40f06e0b4cd9df8daa11e1dec1f3f51fc63424b2 (diff) | |
download | plyr-dbe618c644a525b196466b7254274cc9bde76275.tar.lz plyr-dbe618c644a525b196466b7254274cc9bde76275.tar.xz plyr-dbe618c644a525b196466b7254274cc9bde76275.zip |
Merge pull request #1793 from theprojectsomething/features/postload-captions
Preload TextTracks as per default video element
Diffstat (limited to 'src')
-rw-r--r-- | src/js/captions.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/js/captions.js b/src/js/captions.js index 04da4651..60381f88 100644 --- a/src/js/captions.js +++ b/src/js/captions.js @@ -133,8 +133,12 @@ const captions = { }); // Turn off native caption rendering to avoid double captions + // Note: mode='hidden' forces a track to download. To ensure every track + // isn't downloaded at once, only 'showing' tracks should be reassigned // eslint-disable-next-line no-param-reassign - track.mode = 'hidden'; + if (track.mode === 'showing') { + track.mode = 'hidden'; + } // Add event listener for cue changes on.call(this, track, 'cuechange', () => captions.updateCues.call(this)); @@ -211,6 +215,14 @@ const captions = { // Trigger event (not used internally) triggerEvent.call(this, this.media, active ? 'captionsenabled' : 'captionsdisabled'); } + + // Wait for the call stack to clear before setting mode='hidden' + // on the active track - forcing the browser to download it + setTimeout(() => { + if (active && this.captions.toggled) { + this.captions.currentTrackNode.mode = 'hidden'; + } + }); }, // Set captions by track index |