Multiple players with YouTube embeds on a single page do not initialize
Having multiple JW Players with YouTube embedded videos on a single webpage does not seem to initialize all videos well. The first player works, but all next players only initialize the JW Player skin and not the YouTube video.
While debugging the JW Player source I triggered this exception:
// There was an error calling back an event handler for "ready". Error: Cannot read property 'loaded' of undefined
I think what happens is:
- The first player triggers embedding the YouTube iframe_api and waits for it to load before initializing the video
- Next players don't wait for the iframe_api (window.YT and window.YT.loaded) to be loaded
I have tested this with JW Player 7.0.1 and the latest versions of Chrome, Canary, Firefox and IE11:
http://wim.latour.nl/jwplayer/jwplayer7-multiple-youtube.html
What solves this issue (for now) is loading the YouTube iframe_api myself and initialize the JW Players in the `onYouTubeIframeAPIReady()` callback:
http://wim.latour.nl/jwplayer/jwplayer7-multiple-youtube-with-iframe_api.html