If you dynamically add youtube iframes with JS, you cannot add re-add the tracker. This fix makes it work:
if (window['onYouTubePlayerAPIReady']) {
var p;
for (var i = 0; i < youtube_videos.length; i++) {
p = new window['YT']['Player'](youtube_videos[i]);
p.addEventListener('onStateChange', _ytStateChange);
p.addEventListener('onError', _ytError);
}
} else {
window['onYouTubePlayerAPIReady'] = function () {
var p;
for (var i = 0; i < youtube_videos.length; i++) {
p = new window['YT']['Player'](youtube_videos[i]);
p.addEventListener('onStateChange', _ytStateChange);
p.addEventListener('onError', _ytError);
}
};
}
If you dynamically add youtube iframes with JS, you cannot add re-add the tracker. This fix makes it work: