diff options
author | max <max@max.lan> | 2020-02-25 17:53:44 +0100 |
---|---|---|
committer | max <max@max.lan> | 2020-02-25 17:53:44 +0100 |
commit | 81b41be750c9eddbabafdbd304614d827cd0ca82 (patch) | |
tree | 58dba58b99d9d2a075253164eec48f7d25bc593b /src | |
parent | b12ec094c55e59db77e5e20fb3b26899211eb410 (diff) | |
download | plyr-81b41be750c9eddbabafdbd304614d827cd0ca82.tar.lz plyr-81b41be750c9eddbabafdbd304614d827cd0ca82.tar.xz plyr-81b41be750c9eddbabafdbd304614d827cd0ca82.zip |
preview-thumbnails via src:callback()
Diffstat (limited to 'src')
-rw-r--r-- | src/js/plugins/preview-thumbnails.js | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/js/plugins/preview-thumbnails.js b/src/js/plugins/preview-thumbnails.js index 86eeebc8..e313a01f 100644 --- a/src/js/plugins/preview-thumbnails.js +++ b/src/js/plugins/preview-thumbnails.js @@ -137,19 +137,31 @@ class PreviewThumbnails { throw new Error('Missing previewThumbnails.src config attribute'); } - // If string, convert into single-element list - const urls = is.string(src) ? [src] : src; - // Loop through each src URL. Download and process the VTT file, storing the resulting data in this.thumbnails - const promises = urls.map(u => this.getThumbnail(u)); - - Promise.all(promises).then(() => { + // Resolve promise + const exec_resolve = () => { // Sort smallest to biggest (e.g., [120p, 480p, 1080p]) this.thumbnails.sort((x, y) => x.height - y.height); this.player.debug.log('Preview thumbnails', this.thumbnails); resolve(); - }); + }; + // Via callback() + if( typeof(src) == 'function' ) { + // Ask + this.thumbnails = src(); + // Resolve + exec_resolve(); + } + // VTT urls + else { + // If string, convert into single-element list + const urls = is.string(src) ? [src] : src; + // Loop through each src URL. Download and process the VTT file, storing the resulting data in this.thumbnails + const promises = urls.map(u => this.getThumbnail(u)); + // Resolve + Promise.all(promises).then(exec_resolve); + } }); } |