diff options
author | Sam Potts <sam@potts.es> | 2019-01-26 17:19:58 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-26 17:19:58 +1100 |
commit | a84fc396e8a53fd595c204deff227104b0255865 (patch) | |
tree | 9f9e927b6ecbeba39c2a6dfc1b51b2d750b352db /src/js/plugins/previewThumbnails.js | |
parent | 052e426810d504a01beb05c8bb34f83e190a0679 (diff) | |
parent | 8b57104f8396c4110f217c854099243d8d04ae20 (diff) | |
download | plyr-a84fc396e8a53fd595c204deff227104b0255865.tar.lz plyr-a84fc396e8a53fd595c204deff227104b0255865.tar.xz plyr-a84fc396e8a53fd595c204deff227104b0255865.zip |
Merge branch 'develop' into issues/1316-allow-to-customize-vimeo-url-params
Diffstat (limited to 'src/js/plugins/previewThumbnails.js')
-rw-r--r-- | src/js/plugins/previewThumbnails.js | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/js/plugins/previewThumbnails.js b/src/js/plugins/previewThumbnails.js index 053875c7..3832be5c 100644 --- a/src/js/plugins/previewThumbnails.js +++ b/src/js/plugins/previewThumbnails.js @@ -109,20 +109,22 @@ class PreviewThumbnails { // Download VTT files and parse them getThumbnails() { return new Promise(resolve => { - if (!this.player.config.previewThumbnails.src) { + const { src } = this.player.config.previewThumbnails; + + if (is.empty(src)) { throw new Error('Missing previewThumbnails.src config attribute'); } - // previewThumbnails.src can be string or list. If string, convert into single-element list - const { src } = this.player.config.previewThumbnails; + // 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 + // 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(() => { // 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(); @@ -301,11 +303,20 @@ class PreviewThumbnails { } // Find the desired thumbnail index + // TODO: Handle a video longer than the thumbs where thumbNum is null const thumbNum = this.thumbnails[0].frames.findIndex( frame => this.seekTime >= frame.startTime && this.seekTime <= frame.endTime, ); + const hasThumb = thumbNum >= 0; let qualityIndex = 0; + this.toggleThumbContainer(hasThumb); + + // No matching thumb found + if (!hasThumb) { + return; + } + // Check to see if we've already downloaded higher quality versions of this image this.thumbnails.forEach((thumbnail, index) => { if (this.loadedImages.includes(thumbnail.frames[thumbNum].text)) { |