diff options
author | Sam Potts <sam@potts.es> | 2020-04-24 00:22:17 +1000 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2020-04-24 00:22:17 +1000 |
commit | 2458eaa11b5c2805bcf1e5349ab900485bac325f (patch) | |
tree | 8c38683d043fdfbe8b1dcb385a446de4df7396a1 /src/js/captions.js | |
parent | a97008aeebb19678e5183e7c934e60729857e11b (diff) | |
parent | dbe618c644a525b196466b7254274cc9bde76275 (diff) | |
download | plyr-2458eaa11b5c2805bcf1e5349ab900485bac325f.tar.lz plyr-2458eaa11b5c2805bcf1e5349ab900485bac325f.tar.xz plyr-2458eaa11b5c2805bcf1e5349ab900485bac325f.zip |
Merge branch 'develop' into css-variables
# Conflicts:
# src/js/captions.js
# src/js/config/defaults.js
# src/js/fullscreen.js
# src/js/listeners.js
# src/js/plyr.js
Diffstat (limited to 'src/js/captions.js')
-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 0e6173ca..cf437bde 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 |