From 0e37fbf02c8dee1d01bfc69b0a718d605b423cc5 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 4 Nov 2019 12:13:24 -0800 Subject: [PATCH] feat: option to load text tracks on demand vs preload (#6043) 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 `