Merge pull request #1039 from friday/poster-race-conditions
Fix poster race conditions
This commit is contained in:
@ -158,10 +158,15 @@ const youtube = {
|
||||
// Replace the <iframe> with a <div> due to YouTube API issues
|
||||
const videoId = parseId(source);
|
||||
const id = generateId(player.provider);
|
||||
const container = createElement('div', { id });
|
||||
|
||||
// Get poster, if already set
|
||||
const { poster } = player;
|
||||
|
||||
// Replace media element
|
||||
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)
|
||||
@ -174,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