mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 17:59:55 +02:00
Fix ads on playlists
This commit is contained in:
parent
efaf4457e6
commit
72c7c2666c
1 changed files with 33 additions and 6 deletions
|
@ -166,7 +166,9 @@ function setPlayerListners() {
|
||||||
clearTimeout(promisePlayTimeout);
|
clearTimeout(promisePlayTimeout);
|
||||||
console.log("setPlayerListners: play");
|
console.log("setPlayerListners: play");
|
||||||
//userIsControling = true;
|
//userIsControling = true;
|
||||||
pauseIfIsPlayinAdsInterval = setInterval(function(){pauseIfIsPlayinAds();},500);
|
pauseIfIsPlayinAdsInterval = setInterval(function () {
|
||||||
|
pauseIfIsPlayinAds();
|
||||||
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#mainVideo .vjs-mute-control").click(function () {
|
$("#mainVideo .vjs-mute-control").click(function () {
|
||||||
|
@ -233,7 +235,32 @@ function changeVideoSrcLoad() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
var _reloadAdsTimeout;
|
||||||
|
function reloadAds() {
|
||||||
|
clearTimeout(_reloadAdsTimeout);
|
||||||
|
console.log('reloadAds');
|
||||||
|
if (player) {
|
||||||
|
if (player.isReady_) {
|
||||||
|
console.log('reloadAds is ready');
|
||||||
|
try {
|
||||||
|
if (_adTagUrl) {
|
||||||
|
console.log('player.ima.changeAdTag _adTagUrl', _adTagUrl);
|
||||||
|
player.ima.changeAdTag(_adTagUrl);
|
||||||
|
} else if (player.ima && player.ima.getAdsManager().M) {
|
||||||
|
console.log('player.ima.getAdsManager().M', player.ima.getAdsManager().M);
|
||||||
|
player.ima.changeAdTag(player.ima.getAdsManager().M);
|
||||||
|
}
|
||||||
|
player.ima.requestAds();
|
||||||
|
} catch (e) {
|
||||||
|
console.log('player.ima.requestAds ERROR', e.message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_reloadAdsTimeout = setTimeout(function () {
|
||||||
|
reloadAds();
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -424,7 +451,7 @@ var browserPreventShowed = false;
|
||||||
var playerPlayTimeout;
|
var playerPlayTimeout;
|
||||||
function playerPlay(currentTime) {
|
function playerPlay(currentTime) {
|
||||||
clearTimeout(playerPlayTimeout);
|
clearTimeout(playerPlayTimeout);
|
||||||
if(playerIsPlayingAds()){
|
if (playerIsPlayingAds()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (currentTime) {
|
if (currentTime) {
|
||||||
|
@ -867,7 +894,7 @@ function isPlayNextEnabled() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function avideoAlert(title, msg, type) {
|
function avideoAlert(title, msg, type) {
|
||||||
if(typeof msg == 'undefined'){
|
if (typeof msg == 'undefined') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (msg !== msg.replace(/<\/?[^>]+(>|$)/g, "")) {//it has HTML
|
if (msg !== msg.replace(/<\/?[^>]+(>|$)/g, "")) {//it has HTML
|
||||||
|
@ -988,8 +1015,8 @@ function playerHasAds() {
|
||||||
return ($("#mainVideo_ima-ad-container").length > 0);
|
return ($("#mainVideo_ima-ad-container").length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pauseIfIsPlayinAds(){
|
function pauseIfIsPlayinAds() {
|
||||||
if(!player.paused() && playerHasAds() && playerIsPlayingAds()){
|
if (!player.paused() && playerHasAds() && playerIsPlayingAds()) {
|
||||||
player.pause();
|
player.pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue