Merge pull request #802 from Robbt/fix-playlist-smartblock-remaining
Fix playlist smartblock remaining
This commit is contained in:
commit
162c509ecd
|
@ -83,8 +83,8 @@ $ccAcl->allow('G', 'index')
|
||||||
->allow('H', 'library')
|
->allow('H', 'library')
|
||||||
->allow('H', 'playlist')
|
->allow('H', 'playlist')
|
||||||
->allow('H', 'playouthistory')
|
->allow('H', 'playouthistory')
|
||||||
|
->allow('H', 'listenerstat')
|
||||||
->allow('A', 'playouthistorytemplate')
|
->allow('A', 'playouthistorytemplate')
|
||||||
->allow('A', 'listenerstat')
|
|
||||||
->allow('A', 'user')
|
->allow('A', 'user')
|
||||||
->allow('A', 'systemstatus')
|
->allow('A', 'systemstatus')
|
||||||
->allow('A', 'preference')
|
->allow('A', 'preference')
|
||||||
|
|
|
@ -1622,7 +1622,7 @@ SQL;
|
||||||
|
|
||||||
|
|
||||||
// this function return list of propel object
|
// this function return list of propel object
|
||||||
public function getListofFilesMeetCriteria($show = null)
|
public function getListofFilesMeetCriteria($showLimit = null)
|
||||||
{
|
{
|
||||||
$storedCrit = $this->getCriteria();
|
$storedCrit = $this->getCriteria();
|
||||||
|
|
||||||
|
@ -1782,9 +1782,8 @@ SQL;
|
||||||
$limits['items'] = $storedCrit['limit']['value'];
|
$limits['items'] = $storedCrit['limit']['value'];
|
||||||
} elseif (($storedCrit['limit']['modifier'] == "remaining") ){
|
} elseif (($storedCrit['limit']['modifier'] == "remaining") ){
|
||||||
// show will be null unless being called inside a show instance
|
// show will be null unless being called inside a show instance
|
||||||
if (!(is_null($show))) {
|
if (!(is_null($showLimit))) {
|
||||||
$showInstance = new Application_Model_ShowInstance($show);
|
$limits['time'] = $showLimit;
|
||||||
$limits['time'] = $showInstance->getSecondsRemaining();
|
|
||||||
$limits['items'] = null;
|
$limits['items'] = null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1813,7 +1812,6 @@ SQL;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$out = $qry->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find();
|
$out = $qry->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find();
|
||||||
Logging::info($qry->toString());
|
|
||||||
|
|
||||||
return array("files"=>$out, "limit"=>$limits, "repeat_tracks"=> $repeatTracks, "overflow_tracks"=> $overflowTracks, "count"=>$out->count());
|
return array("files"=>$out, "limit"=>$limits, "repeat_tracks"=> $repeatTracks, "overflow_tracks"=> $overflowTracks, "count"=>$out->count());
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
@ -1823,7 +1821,6 @@ SQL;
|
||||||
}
|
}
|
||||||
public static function organizeSmartPlaylistCriteria($p_criteria)
|
public static function organizeSmartPlaylistCriteria($p_criteria)
|
||||||
{
|
{
|
||||||
Logging::info($p_criteria);
|
|
||||||
$fieldNames = array('sp_criteria_field', 'sp_criteria_modifier', 'sp_criteria_value', 'sp_criteria_extra', 'sp_criteria_datetime_select', 'sp_criteria_extra_datetime_select');
|
$fieldNames = array('sp_criteria_field', 'sp_criteria_modifier', 'sp_criteria_value', 'sp_criteria_extra', 'sp_criteria_datetime_select', 'sp_criteria_extra_datetime_select');
|
||||||
$output = array();
|
$output = array();
|
||||||
foreach ($p_criteria as $ele) {
|
foreach ($p_criteria as $ele) {
|
||||||
|
@ -1862,7 +1859,6 @@ SQL;
|
||||||
$output['etc'][$ele['name']] = $ele['value'];
|
$output['etc'][$ele['name']] = $ele['value'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Logging::info($output);
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
public static function getAllBlockFiles()
|
public static function getAllBlockFiles()
|
||||||
|
|
|
@ -213,6 +213,10 @@ final class Application_Model_Scheduler
|
||||||
*/
|
*/
|
||||||
private function retrieveMediaFiles($id, $type, $show)
|
private function retrieveMediaFiles($id, $type, $show)
|
||||||
{
|
{
|
||||||
|
// if there is a show we need to set a show limit to pass to smart blocks in case they use time remaining
|
||||||
|
$showInstance = new Application_Model_ShowInstance($show);
|
||||||
|
$showLimit = $showInstance->getSecondsRemaining();
|
||||||
|
|
||||||
$files = array();
|
$files = array();
|
||||||
if ($type === "audioclip") {
|
if ($type === "audioclip") {
|
||||||
$file = CcFilesQuery::create()->findPK($id, $this->con);
|
$file = CcFilesQuery::create()->findPK($id, $this->con);
|
||||||
|
@ -241,7 +245,8 @@ final class Application_Model_Scheduler
|
||||||
} elseif ($type === "playlist") {
|
} elseif ($type === "playlist") {
|
||||||
$pl = new Application_Model_Playlist($id);
|
$pl = new Application_Model_Playlist($id);
|
||||||
$contents = $pl->getContents();
|
$contents = $pl->getContents();
|
||||||
|
// because the time remaining is not updated until after the schedule inserts we need to track it for
|
||||||
|
// the entire add vs. querying on the smartblock level
|
||||||
foreach ($contents as $plItem) {
|
foreach ($contents as $plItem) {
|
||||||
if ($plItem['type'] == 0) {
|
if ($plItem['type'] == 0) {
|
||||||
$data["id"] = $plItem['item_id'];
|
$data["id"] = $plItem['item_id'];
|
||||||
|
@ -278,7 +283,7 @@ final class Application_Model_Scheduler
|
||||||
} else {
|
} else {
|
||||||
$defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn();
|
$defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn();
|
||||||
$defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut();
|
$defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut();
|
||||||
$dynamicFiles = $bl->getListOfFilesUnderLimit($show);
|
$dynamicFiles = $bl->getListOfFilesUnderLimit($showLimit);
|
||||||
foreach ($dynamicFiles as $f) {
|
foreach ($dynamicFiles as $f) {
|
||||||
$fileId = $f['id'];
|
$fileId = $f['id'];
|
||||||
$file = CcFilesQuery::create()->findPk($fileId);
|
$file = CcFilesQuery::create()->findPk($fileId);
|
||||||
|
@ -301,6 +306,9 @@ final class Application_Model_Scheduler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if this is a playlist it might contain multiple time remaining smart blocks
|
||||||
|
// since the schedule isn't updated until after this insert we need to keep tally
|
||||||
|
$showLimit -= $this->timeLengthOfFiles($files);
|
||||||
}
|
}
|
||||||
} elseif ($type == "stream") {
|
} elseif ($type == "stream") {
|
||||||
//need to return
|
//need to return
|
||||||
|
@ -337,7 +345,7 @@ final class Application_Model_Scheduler
|
||||||
} else {
|
} else {
|
||||||
$defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn();
|
$defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn();
|
||||||
$defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut();
|
$defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut();
|
||||||
$dynamicFiles = $bl->getListOfFilesUnderLimit($show);
|
$dynamicFiles = $bl->getListOfFilesUnderLimit($showLimit);
|
||||||
foreach ($dynamicFiles as $f) {
|
foreach ($dynamicFiles as $f) {
|
||||||
$fileId = $f['id'];
|
$fileId = $f['id'];
|
||||||
$file = CcFilesQuery::create()->findPk($fileId);
|
$file = CcFilesQuery::create()->findPk($fileId);
|
||||||
|
@ -993,6 +1001,7 @@ final class Application_Model_Scheduler
|
||||||
$this->calculateCrossfades($instanceId);
|
$this->calculateCrossfades($instanceId);
|
||||||
}
|
}
|
||||||
}//for each instance
|
}//for each instance
|
||||||
|
|
||||||
}//for each schedule location
|
}//for each schedule location
|
||||||
|
|
||||||
$endProfile = microtime(true);
|
$endProfile = microtime(true);
|
||||||
|
@ -1294,6 +1303,20 @@ final class Application_Model_Scheduler
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* This is used to determine the duration of a files array
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function timeLengthOfFiles($files) {
|
||||||
|
$timeLength = 0;
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$timeLength += Application_Common_DateHelper::playlistTimeToSeconds($file['cliplength']);
|
||||||
|
$timeLength += $file['fadein'];
|
||||||
|
$timeLength += $file['fadeout'];
|
||||||
|
}
|
||||||
|
return $timeLength;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Used for cancelling the current show instance.
|
* Used for cancelling the current show instance.
|
||||||
|
|
Loading…
Reference in New Issue