From 9ab12f8bc2ffb61af4e9fdcafceda520b4c1dc1c Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 4 Nov 2019 11:19:30 -0800 Subject: [PATCH] Option to load text tracks on demand vs preload Reimplementation of https://github.com/videojs/video.js/pull/2192 on current code. Seems to work but has not been carefully tested, especially on conditions such as slow networks and complex tracks. For https://github.com/videojs/video.js/issues/5252 A `preloadTextTracks` tech option is added, set to true by default, to keep current behavior intact. Alternate behavior can be enabled by setting this to false. This delays loading of the VTT cue files until they are selected. For sites like Wikipedia that tend to have large numbers of crowdsourced subtitles and can show many files together on one page, this saves a lot of unnecessary network transfer and API hits. Does mean there may be dropped cues while switching to a track that requires on-demand loading. Example usage: videojs(element, { html5: { preloadTextTracks: false } }; --- docs/guides/options.md | 9 +++++++++ src/js/tech/tech.js | 2 ++ src/js/tracks/text-track.js | 15 ++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/guides/options.md b/docs/guides/options.md index b86cfc112e..89dda7782d 100644 --- a/docs/guides/options.md +++ b/docs/guides/options.md @@ -58,6 +58,7 @@ * [nativeAudioTracks](#nativeaudiotracks) * [nativeTextTracks](#nativetexttracks) * [nativeVideoTracks](#nativevideotracks) + * [preloadTextTracks](#preloadtexttracks) ## Standard `