1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 19:42:38 +02:00

Fix ads on playlists

This commit is contained in:
DanielnetoDotCom 2021-03-03 17:59:50 -03:00
parent 8d44f61f97
commit a99b6c8695

View file

@ -246,32 +246,30 @@ function reloadAds() {
} }
function reloadAdsIfIsReady() { function reloadAdsIfIsReady() {
console.log('reloadAdsIfIsReady player.readyState() = '+player.readyState()); console.log('reloadAdsIfIsReady player.readyState() = ' + player.readyState());
clearTimeout(_reloadAdsTimeout); clearTimeout(_reloadAdsTimeout);
if (player.ima) { if (player.ima) {
if (player.readyState() > 2) { console.log('reloadAdsIfIsReady is ready');
console.log('reloadAdsIfIsReady is ready'); try {
try { var adTagUrl;
var adTagUrl; if (_adTagUrl) {
if (_adTagUrl) { console.log('reloadAdsIfIsReady _adTagUrl', _adTagUrl);
console.log('reloadAdsIfIsReady _adTagUrl', _adTagUrl); adTagUrl = _adTagUrl;
adTagUrl = _adTagUrl; } else if (player.ima && player.ima.getAdsManager().M) {
} else if (player.ima && player.ima.getAdsManager().M) { console.log('reloadAdsIfIsReady player.ima.getAdsManager().M', player.ima.getAdsManager().M);
console.log('reloadAdsIfIsReady player.ima.getAdsManager().M', player.ima.getAdsManager().M); adTagUrl = player.ima.getAdsManager().M;
adTagUrl = player.ima.getAdsManager().M;
}
//player.ima.setContentWithAdTag(null, adTagUrl, true);
//player.ima.initializeAdDisplayContainer();
player.ima.changeAdTag(adTagUrl);
player.ima.requestAds();
} catch (e) {
console.log('reloadAdsIfIsReady ERROR', e.message);
} }
} else { //player.ima.setContentWithAdTag(null, adTagUrl, true);
_reloadAdsTimeout = setTimeout(function () { //player.ima.initializeAdDisplayContainer();
reloadAdsIfIsReady(); player.ima.changeAdTag(adTagUrl);
}, 100); player.ima.requestAds();
} catch (e) {
console.log('reloadAdsIfIsReady ERROR', e.message);
} }
} else {
_reloadAdsTimeout = setTimeout(function () {
reloadAdsIfIsReady();
}, 100);
} }
} }