|
230 | 230 |
|
231 | 231 | AblePlayer.prototype.getVimeoPosterUrl = function (vimeoId, width) { |
232 | 232 |
|
233 | | - // this is a placeholder, copied from getYouTubePosterUrl() |
234 | | - // Vimeo doesn't seem to have anything similar, |
235 | | - // Vimeo API for images: https://vimeo.com/api/v2/video/328769500.json |
236 | | - // will require an unauthenticated API query. |
237 | | - |
238 | | - // return a URL for retrieving a YouTube poster image |
239 | | - // supported values of width: 120, 320, 480, 640 |
240 | | - |
241 | | - var url = 'https://img.youtube.com/vi/' + youTubeId; |
242 | | - if (width == '120') { |
243 | | - // default (small) thumbnail, 120 x 90 |
244 | | - return url + '/default.jpg'; |
245 | | - } else if (width == '320') { |
246 | | - // medium quality thumbnail, 320 x 180 |
247 | | - return url + '/hqdefault.jpg'; |
248 | | - } else if (width == '480') { |
249 | | - // high quality thumbnail, 480 x 360 |
250 | | - return url + '/hqdefault.jpg'; |
251 | | - } else if (width == '640') { |
252 | | - // standard definition poster image, 640 x 480 |
253 | | - return url + '/sddefault.jpg'; |
254 | | - } |
255 | | - return false; |
| 233 | + // Vimeo Oembed only returns a 640px width image. Hope at some point there's an alternative. |
| 234 | + var url = 'http://vimeo.com/api/oembed.json?url=https://vimeo.com/' + vimeoId, imageUrl = ''; |
| 235 | + console.log( url ); |
| 236 | + fetch( url ).then( response => { |
| 237 | + |
| 238 | + return response.json(); |
| 239 | + }) |
| 240 | + .then( json => { |
| 241 | + imageUrl = json.thumbnail_url; |
| 242 | + }) |
| 243 | + .catch( error => { |
| 244 | + if (thisObj.debug) { |
| 245 | + console.log( 'Vimeo API query: ' + error ); |
| 246 | + } |
| 247 | + }); |
| 248 | + |
| 249 | + return imageUrl; |
256 | 250 | }; |
257 | 251 |
|
258 | 252 | AblePlayer.prototype.getVimeoId = function (url) { |
|
0 commit comments