diff options
author | Albin Larsson <mail@albinlarsson.com> | 2018-06-15 23:56:47 +0200 |
---|---|---|
committer | Albin Larsson <mail@albinlarsson.com> | 2018-06-15 23:56:47 +0200 |
commit | 115f352ade7fbe133a42fd434dbcc1fca13287a7 (patch) | |
tree | 23e95907529fedd5a420f1f2712465470b2b7c7d /src/js/plugins | |
parent | 2af60c5c0db42655b9adb14a518fc94c2c0f6222 (diff) | |
download | plyr-115f352ade7fbe133a42fd434dbcc1fca13287a7.tar.lz plyr-115f352ade7fbe133a42fd434dbcc1fca13287a7.tar.xz plyr-115f352ade7fbe133a42fd434dbcc1fca13287a7.zip |
Respect call order and prioritize public API calls for setting poster, in order to avoid race conditions
Diffstat (limited to 'src/js/plugins')
-rw-r--r-- | src/js/plugins/vimeo.js | 2 | ||||
-rw-r--r-- | src/js/plugins/youtube.js | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/js/plugins/vimeo.js b/src/js/plugins/vimeo.js index 21b1dd0a..09339229 100644 --- a/src/js/plugins/vimeo.js +++ b/src/js/plugins/vimeo.js @@ -140,7 +140,7 @@ const vimeo = { url.pathname = `${url.pathname.split('_')[0]}.jpg`; // Set and show poster - ui.setPoster.call(player, url.href); + ui.setPoster.call(player, url.href).catch(() => {}); }); // Setup instance diff --git a/src/js/plugins/youtube.js b/src/js/plugins/youtube.js index 8c4ebc1c..94369ece 100644 --- a/src/js/plugins/youtube.js +++ b/src/js/plugins/youtube.js @@ -166,7 +166,7 @@ const youtube = { const container = createElement('div', { id, poster }); player.media = replaceElement(container, player.media); - // Set poster image + // Id to poster wrapper const posterSrc = format => `https://img.youtube.com/vi/${videoId}/${format}default.jpg`; // Check thumbnail images in order of quality, but reject fallback thumbnails (120px wide) @@ -179,7 +179,8 @@ const youtube = { if (!posterSrc.includes('maxres')) { player.elements.poster.style.backgroundSize = 'cover'; } - }); + }) + .catch(() => {}); // Setup instance // https://developers.google.com/youtube/iframe_api_reference |