Fixed autoplaylist repeat to fill show

This commit is contained in:
Robb Ebright 2017-04-01 00:56:55 -04:00
parent 8bd93e3f6d
commit 8a92c80bcb
2 changed files with 40 additions and 4 deletions

View File

@ -31,8 +31,23 @@ class AutoPlaylistManager {
$playlistid = $si->GetAutoPlaylistId();
Logging::info("Scheduling $playlistid");
// call the addPlaylist to show function and don't check for user permission to avoid call to non-existant user object
$si->addPlaylistToShow($playlistid, false);
while ($si->getPercentScheduled() < 100) {
$sid = $si->getShowId();
$playlistrepeat = new Application_Model_Show($sid);
if ($playlistrepeat->getAutoPlaylistRepeat()) {
$full = false;
while(!$full) {
$si = new Application_Model_ShowInstance($autoplaylist->getDbId());
$si->addPlaylistToShow($playlistid, false);
$ps = $si->getPercentScheduled();
//Logging::info("The total percent scheduled is % $ps");
if ($ps > 100) {
$full = true;
}
}
}
else {
$si->addPlaylistToShow($playlistid, false);
}
$si->setAutoPlaylistBuilt(true);

View File

@ -236,14 +236,19 @@ SQL;
{
$ts = intval($this->_showInstance->getDbLastScheduled("U")) ? : 0;
$id = $this->_showInstance->getDbId();
$lastid = $this->getLastAudioItemId();
// Logging::info("The last id is $lastid");
$scheduler = new Application_Model_Scheduler($checkUserPerm);
$scheduler->scheduleAfter(
array(array("id" => 0, "instance" => $id, "timestamp" => $ts)),
array(array("id" => $lastid, "instance" => $id, "timestamp" => $ts)),
array(array("id" => $pl_id, "type" => "playlist"))
);
}
/**
* Add a media file as the last item in the show.
*
@ -649,12 +654,28 @@ SQL;
return $results;
}
public function getLastAudioItemId()
{
$con = Propel::getConnection();
$sql = "SELECT id FROM cc_schedule "
."WHERE instance_id = :instanceId "
."ORDER BY ends DESC "
."LIMIT 1";
$query = Application_Common_Database::prepareAndExecute( $sql,
array(':instanceId' => $this->_instanceId), 'column');
return ($query !== false) ? $query : null;
}
public function getLastAudioItemEnd()
{
$con = Propel::getConnection();
$sql = "SELECT ends FROM cc_schedule "
."WHERE instance_id = :instanceId"
."WHERE instance_id = :instanceId "
."ORDER BY ends DESC "
."LIMIT 1";