cinera_player_pre.js: Fix YouTube initialisation

Initialise the player if the YouTube API loads before us
This commit is contained in:
Matt Mascarenhas 2021-09-01 16:38:23 +01:00
parent c839e2ed85
commit ee788b0c30
2 changed files with 21 additions and 14 deletions

View File

@ -23,7 +23,7 @@ typedef struct
version CINERA_APP_VERSION = {
.Major = 0,
.Minor = 10,
.Patch = 0
.Patch = 1
};
#include <stdarg.h> // NOTE(matt): varargs

View File

@ -634,19 +634,26 @@ Player.initializePlatform = function(platform_id, callback) {
} break;
case vod_platform.YOUTUBE:
{
if (window.APYoutubeAPIReady === undefined) {
window.APYoutubeAPIReady = false;
window.APCallbacks = (callback ? [callback] : []);
window.onYouTubeIframeAPIReady = function() {
window.APYoutubeAPIReady = true;
for (var i = 0; i < APCallbacks.length; ++i) {
APCallbacks[i]();
}
};
} else if (window.APYoutubeAPIReady === false) {
window.APCallbacks.push(callback);
} else if (window.APYoutubeAPIReady === true) {
callback();
if(window.YT && window.YT.loaded)
{
callback()
}
else
{
if (window.APYoutubeAPIReady === undefined) {
window.APYoutubeAPIReady = false;
window.APCallbacks = (callback ? [callback] : []);
window.onYouTubeIframeAPIReady = function() {
window.APYoutubeAPIReady = true;
for (var i = 0; i < APCallbacks.length; ++i) {
APCallbacks[i]();
}
};
} else if (window.APYoutubeAPIReady === false) {
window.APCallbacks.push(callback);
} else if (window.APYoutubeAPIReady === true) {
callback();
}
}
} break;
}