Skip to content

Commit

Permalink
Preroll and Postroll image fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DanieL authored and DanieL committed May 3, 2022
1 parent 801b785 commit 79ad533
Show file tree
Hide file tree
Showing 8 changed files with 1,047 additions and 908 deletions.
1,730 changes: 865 additions & 865 deletions objects/Object.php

Large diffs are not rendered by default.

41 changes: 26 additions & 15 deletions objects/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4560,7 +4560,7 @@ function isLive() {
if (!empty($isLive)) {
$live = getLiveKey();
if (empty($live)) {
$live = ['key' => false, 'live_servers_id' => false, 'live_index' => false];
$live = ['key' => false, 'live_servers_id' => false, 'live_index' => false, 'live_schedule' => false, 'users_id' => false];
}
$live['liveLink'] = isLiveLink();
return $live;
Expand Down Expand Up @@ -4595,8 +4595,15 @@ function setLiveKey($key, $live_servers_id, $live_index = '') {
$live_index = $parameters['live_index'];
}
$key = Live::getLiveKeyFromRequest($key, $live_index, $parameters['playlists_id_live']);

$getLiveKey = ['key' => $key, 'live_servers_id' => intval($live_servers_id), 'live_index' => $live_index, 'cleanKey' => $cleanKey];
$lt = LiveTransmition::getFromKey($key);
$live_schedule = 0;
$users_id = 0;
if (!empty($lt['live_schedule_id'])) {
$live_schedule = $lt['live_schedule_id'];
$live_servers_id = $lt['live_servers_id'];
$users_id = $lt['users_id'];
}
$getLiveKey = ['key' => $key, 'live_servers_id' => intval($live_servers_id), 'live_index' => $live_index, 'cleanKey' => $cleanKey, 'live_schedule' => $live_schedule, 'users_id' => $users_id];
return $getLiveKey;
}

Expand Down Expand Up @@ -6949,15 +6956,19 @@ function getStatsNotifications($force_recreate = false, $listItIfIsAdminOrOwner
$u = User::getFromUsername($value['user']);
$json['applications'][$key]['users_id'] = $u['id'];
}
if (!empty($json['applications'][$key]['key']) && $json['applications'][$key]["type"] === "live") {
// make sure it is online
$lth = new LiveTransmitionHistory();
$lth->setTitle($json['applications'][$key]['title']);
$lth->setKey($json['applications'][$key]['key']);
$lth->setUsers_id($json['applications'][$key]['users_id']);
$lth->setLive_servers_id($json['applications'][$key]['live_servers_id']);
$json['applications'][$key]['live_transmitions_history_id'] = $lth->save();
}
/*
* It was creating a duplicated records
if (!empty($json['applications'][$key]['key']) && $json['applications'][$key]["type"] === "live") {
// make sure it is online
$lth = new LiveTransmitionHistory();
$lth->setTitle($json['applications'][$key]['title']);
$lth->setKey($json['applications'][$key]['key']);
$lth->setUsers_id($json['applications'][$key]['users_id']);
$lth->setLive_servers_id($json['applications'][$key]['live_servers_id']);
$json['applications'][$key]['live_transmitions_history_id'] = $lth->save();
}
*
*/
}
}
$cache = ObjectYPT::setCache($cacheName, $json);
Expand Down Expand Up @@ -8141,20 +8152,20 @@ function _ob_end_clean() {
*/
}

function pluginsRequired($arrayPluginName, $featureName='') {
function pluginsRequired($arrayPluginName, $featureName = '') {
global $global;
$obj = new stdClass();
$obj->error = false;
$obj->msg = '';

foreach ($arrayPluginName as $name) {
$loadPluginFile = "{$global['systemRootPath']}plugin/{$name}/{$name}.php";
if (!file_exists($loadPluginFile)) {
$obj->error = true;
$obj->msg = "Plugin {$name} is required for $featureName ";
break;
}
if(!AVideoPlugin::isEnabledByName($name)){
if (!AVideoPlugin::isEnabledByName($name)) {
$obj->error = true;
$obj->msg = "Please enable Plugin {$name} it is required for $featureName ";
break;
Expand Down
64 changes: 56 additions & 8 deletions plugin/Live/Live.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,20 +571,21 @@ public function getHeadCode() {
$liveImgTimeInSecondsPreroll = 'false';
$liveImgCloseTimeInSecondsPostroll = 'false';
$liveImgTimeInSecondsPostroll = 'false';
if (self::prerollPosterExists()) {
//var_dump('',$live, self::prerollPosterExists($live['users_id'], $live['live_servers_id'], $live['live_schedule']));exit;
if (self::prerollPosterExists($live['users_id'], $live['live_servers_id'], $live['live_schedule'])) {

$path = self::getPrerollPosterImage();
$path = self::getPrerollPosterImage($live['users_id'], $live['live_servers_id'], $live['live_schedule']);
$prerollPoster = "'" . getURL($path) . "'";

$times = self::getPrerollPosterImageTimes();
$times = self::getPrerollPosterImageTimes($live['users_id'], $live['live_servers_id'], $live['live_schedule']);
$liveImgCloseTimeInSecondsPreroll = $times->liveImgCloseTimeInSeconds;
$liveImgTimeInSecondsPreroll = $times->liveImgTimeInSeconds;
//var_dump($times);
}
if (self::postrollPosterExists()) {
$postrollPoster = "'" . getURL(self::getPostrollPosterImage()) . "'";
if (self::postrollPosterExists($live['users_id'], $live['live_servers_id'], $live['live_schedule'])) {
$postrollPoster = "'" . getURL(self::getPostrollPosterImage($live['users_id'], $live['live_servers_id'], $live['live_schedule'])) . "'";

$times = self::getPostrollPosterImageTimes();
$times = self::getPostrollPosterImageTimes($live['users_id'], $live['live_servers_id'], $live['live_schedule']);
$liveImgCloseTimeInSecondsPostroll = $times->liveImgCloseTimeInSeconds;
$liveImgTimeInSecondsPostroll = $times->liveImgTimeInSeconds;
//var_dump($times);
Expand Down Expand Up @@ -2186,7 +2187,7 @@ public static function isKeyLiveInStats($key, $live_servers_id = 0, $live_index
$_isLiveFromKey = [];
}

if (isset($_isLiveFromKey[$index])) {
if (empty($force_recreate) && isset($_isLiveFromKey[$index])) {
_error_log('Live::isKeyLiveInStats key is already set');
return $_isLiveFromKey[$index];
}
Expand Down Expand Up @@ -3245,6 +3246,54 @@ public static function getMediaSessionPosters($users_id, $live_servers_id, $live
}
return false;
}

public static function getInfo($key, $live_servers_id = null){

$array = array(
'key' => $key,
'live_schedule_id' => 0,
'users_id' => 0,
'live_servers_id' => $live_servers_id,
'history' => false,
'isLive' => false,
'isFinished' => false,
'finishedDateTime' => __('Not finished'),
'finishedSecondsAgo' => 0,
'finishedHumanAgo' => __('Not finished'),
'isStarded' => false,
'startedDateTime' => __('Not started'),
'startedSecondsAgo' => 0,
'startedHumanAgo' => __('Not started'),
);

$lt = LiveTransmition::getFromKey($key);
if(empty($lt)){
return $array;
}
$array['transmission'] = $lt;
$array['live_schedule_id'] = $lt['live_schedule_id'];
$array['users_id'] = $lt['users_id'];

$lth = LiveTransmitionHistory::getLatest($key, $live_servers_id);
if(empty($lth)){
return $array;
}
$array['history'] = $lth;
$array['isLive'] = true;
$array['isStarded'] = true;
$array['startedDateTime'] = $lth['created'];
$array['startedSecondsAgo'] = secondsIntervalFromNow($lth['created'], true);
$array['startedHumanAgo'] = __('Started').' '.humanTimingAgo($lth['created']);

if(!empty($lth['finished'])){
$array['isLive'] = false;
$array['isFinished'] = true;
$array['finishedDateTime'] = $livet['finished'];
$array['finishedSecondsAgo'] = secondsIntervalFromNow($lth['finished'], true);
$array['finishedHumanAgo'] = __('Finished').' '.humanTimingAgo($lth['finished']);
}
return $array;
}

}

Expand Down Expand Up @@ -3426,5 +3475,4 @@ public function getRTMPLinkWithOutKey($short = true) {
$lt = LiveTransmition::getFromKey($this->key);
return Live::getServerURL($this->key, $lt['users_id'], $short);
}

}
2 changes: 2 additions & 0 deletions plugin/Live/Objects/LiveTransmition.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ public static function keyExists($key, $checkSchedule = true)
if ($res) {
$row = $data;
if (!empty($row)) {
$row['live_schedule_id'] = 0;
$row['scheduled'] = 0;
}
if (!empty($row)) {
Expand All @@ -293,6 +294,7 @@ public static function keyExists($key, $checkSchedule = true)
$row = Live_schedule::keyExists($key);
if (!empty($row)) {
$row['scheduled'] = 1;
$row['live_schedule_id'] = $row['id'];
}
}

Expand Down
23 changes: 19 additions & 4 deletions plugin/Live/Objects/LiveTransmitionHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public function setJson($json) {

public function setTitle($title) {
global $global;
$Char = "‌";
$title = str_replace($Char, '', $title);
$title = $global['mysqli']->real_escape_string($title);
$this->title = $title;
}
Expand Down Expand Up @@ -352,7 +354,6 @@ public static function isLive($key) {

public static function getLatest($key, $live_servers_id = null, $active=false) {
global $global;

$key = $global['mysqli']->real_escape_string($key);

if (empty($key)) {
Expand All @@ -373,7 +374,7 @@ public static function getLatest($key, $live_servers_id = null, $active=false) {
}
$sql .= " ORDER BY created DESC LIMIT 1";
//var_dump($sql, $key);exit;

//_error_log($sql);
$res = sqlDAL::readSql($sql);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
Expand Down Expand Up @@ -630,7 +631,8 @@ public static function getActiveLiveFromUser($users_id, $live_servers_id = '', $

public function save() {
global $global;

$global['mysqli']->commit();
/*
$activeLive = self::getActiveLiveFromUser($this->users_id, $this->live_servers_id, $this->key);
if(!empty($activeLive)){
//_error_log("LiveTransmitionHistory::save: active live found ". json_encode($activeLive));
Expand All @@ -641,6 +643,19 @@ public function save() {
}
}else{
//_error_log("LiveTransmitionHistory::save: active live NOT found ");
}
*
*/
$activeLive = self::getLatest($this->key, $this->live_servers_id, true);
if(!empty($activeLive)){
_error_log("LiveTransmitionHistory::save: active live found ". json_encode($activeLive));
foreach ($activeLive as $key => $value) {
if(empty($this->$key)){
$this->$key = $value;
}
}
}else{
_error_log("LiveTransmitionHistory::save: active live NOT found ". _json_encode(array($this->key, $this->live_servers_id)));
}
if(empty($this->id)){
// if is creating a new make sure all
Expand All @@ -659,7 +674,7 @@ public function save() {
$this->total_viewers = intval($this->total_viewers);

$id = parent::save();
//_error_log("LiveTransmitionHistory::save: id=$id ($this->users_id, $this->live_servers_id, $this->key) ". json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)));
_error_log("LiveTransmitionHistory::save: id=$id ($this->users_id, $this->live_servers_id, $this->key) ". json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)));
$global['mysqli']->commit();
return $id;
}
Expand Down
58 changes: 44 additions & 14 deletions plugin/Live/view/Live_schedule/uploadPoster.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,49 @@
<select class="form-control" id="liveImgTimeInSeconds">
<?php
$seconds = __('Seconds');
for ($i = 0; $i < 10; $i++) {
echo "<option value=\"{$i}\">{$i} {$seconds}</option>";
}
?>
<?php
for ($i = 10; $i < 600; $i += 5) {
$selected = '';
if ($i == $defaultTIme) {
$selected = 'selected';
<optgroup label="<?php echo $seconds; ?>">
<?php
for ($i = 0; $i < 10; $i++) {
echo "<option value=\"{$i}\">{$i} {$seconds}</option>";
}
echo "<option value=\"{$i}\" {$selected}>{$i} {$seconds}</option>";
}
?>
<?php
for ($i = 10; $i < 60; $i += 5) {
$selected = '';
if ($i == $defaultTIme) {
$selected = 'selected';
}
echo "<option value=\"{$i}\" {$selected}>{$i} {$seconds}</option>";
}
?>

</optgroup>
<?php
$minutes = __('Minutes');
?>
<optgroup label="<?php echo $minutes; ?>">
<?php
for ($i = 60; $i < 600; $i += 60) {
$selected = '';
if ($i == $defaultTIme) {
$selected = 'selected';
}
$min = intval($i / 60);
echo "<option value=\"{$i}\" {$selected}>{$min} {$minutes}</option>";
}
?>
<?php
for ($i = 600; $i <= 3600; $i += 300) {
$selected = '';
if ($i == $defaultTIme) {
$selected = 'selected';
}
$min = intval($i / 60);
echo "<option value=\"{$i}\" {$selected}>{$min} {$minutes}</option>";
}
?>
</optgroup>
</select>
</div>
<div class="form-group">
Expand Down Expand Up @@ -189,22 +219,22 @@ function <?php echo $callBackJSFunction; ?>(image) {
console.log('posterTypeBtn click', posterType, imageToRelaod);
<?php
echo $croppie1['restartCroppie'] . "(imageToRelaod);";
?>
?>
var liveImgCloseTimeInSeconds = -1;
var liveImgTimeInSeconds = <?php echo $defaultTIme; ?>;
if (jsonFile) {
modal.showPleaseWait();
$.getJSON(jsonFile, function (data) {
if(data){
if (data) {
liveImgCloseTimeInSeconds = data.liveImgCloseTimeInSeconds;
liveImgTimeInSeconds = data.liveImgTimeInSeconds;
}
}).always(function() {
}).always(function () {
modal.hidePleaseWait();
$('#liveImgCloseTimeInSeconds').val(liveImgCloseTimeInSeconds);
$('#liveImgTimeInSeconds').val(liveImgTimeInSeconds);
});
}else{
} else {
$('#liveImgCloseTimeInSeconds').val(liveImgCloseTimeInSeconds);
$('#liveImgTimeInSeconds').val(liveImgTimeInSeconds);
}
Expand Down
Loading

0 comments on commit 79ad533

Please sign in to comment.