Respect call order and prioritize public API calls for setting poster, in order to avoid race conditions
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user