mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-06 03:50:04 +02:00
add option to preroll livestream
This commit is contained in:
parent
3e1c9efd6c
commit
22cbef74bc
3 changed files with 36 additions and 23 deletions
|
@ -40,6 +40,8 @@ class AD_Server extends PluginAbstract {
|
|||
|
||||
public function getEmptyDataObject() {
|
||||
$obj = new stdClass();
|
||||
$obj->prerollLive = true;
|
||||
self::addDataObjectHelper('prerollLive', 'Pre Roll Live Stream');
|
||||
$obj->start = true;
|
||||
self::addDataObjectHelper('start', 'Show Pre-Roll ads');
|
||||
$obj->mid25Percent = true;
|
||||
|
@ -145,8 +147,13 @@ class AD_Server extends PluginAbstract {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (empty($_GET['videoName'])) {
|
||||
return false;
|
||||
$obj = $this->getDataObject();
|
||||
if($obj->prerollLive){
|
||||
if (isLive()) {
|
||||
return true;
|
||||
} else if (isLiveLink()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// count it each 2 seconds
|
||||
if (empty($_SESSION['lastAdShowed']) || $_SESSION['lastAdShowed'] + 2 <= time()) {
|
||||
|
@ -161,7 +168,6 @@ class AD_Server extends PluginAbstract {
|
|||
}
|
||||
}
|
||||
//_error_log("Show Ads Count {$_SESSION['showAdsCount']}");
|
||||
$obj = $this->getDataObject();
|
||||
if (!empty($obj->showAdsOnEachVideoView->value) && $_SESSION['showAdsCount'] % $obj->showAdsOnEachVideoView->value === 0) {
|
||||
return true;
|
||||
}
|
||||
|
@ -169,7 +175,7 @@ class AD_Server extends PluginAbstract {
|
|||
}
|
||||
|
||||
public function getHeadCode() {
|
||||
$obj = $this->getDataObject();
|
||||
//$obj = $this->getDataObject();
|
||||
if (!$this->canLoadAds()) {
|
||||
return "";
|
||||
}
|
||||
|
@ -320,6 +326,11 @@ class AD_Server extends PluginAbstract {
|
|||
|
||||
$selectedOptions = $this->getRandomPositions();
|
||||
|
||||
if(isLive() || isLiveLink()){
|
||||
if($obj->prerollLive){
|
||||
$vmaps[] = new VMAP("start", new VAST(100));
|
||||
}
|
||||
}else{
|
||||
if (!empty($obj->start) && in_array(1, $selectedOptions)) {
|
||||
$vmaps[] = new VMAP("start", new VAST(1));
|
||||
}
|
||||
|
@ -338,6 +349,7 @@ class AD_Server extends PluginAbstract {
|
|||
if (!empty($obj->end) && in_array(5, $selectedOptions)) {
|
||||
$vmaps[] = new VMAP("end", new VAST(5), $video_length);
|
||||
}
|
||||
}
|
||||
|
||||
return $vmaps;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@ if (empty($_GET['vmap_id'])) {
|
|||
}
|
||||
|
||||
$vmaps = AD_Server::getVMAPSFromRequest();
|
||||
?><?xml version="1.0" encoding="UTF-8"?>
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>';
|
||||
?>
|
||||
<vmap:VMAP xmlns:vmap="http://www.iab.net/videosuite/vmap" version="1.0">
|
||||
<?php
|
||||
foreach ($vmaps as $key => $value) {
|
||||
|
|
|
@ -1710,7 +1710,7 @@ function fixAdSize() {
|
|||
}
|
||||
|
||||
function playerIsPlayingAds() {
|
||||
return ($("#mainVideo_ima-ad-container").length && $("#mainVideo_ima-ad-container").is(':visible')) && player.ima.getAdsManager().getRemainingTime() > 0;
|
||||
return ($("#mainVideo_ima-ad-container").length && $("#mainVideo_ima-ad-container").is(':visible')) && player.ima.getAdsManager() != null && player.ima.getAdsManager().getRemainingTime() > 0;
|
||||
}
|
||||
|
||||
function playerHasAds() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue