CC-5251 : Playlist length is not shown in Library

This commit is contained in:
Naomi Aro 2013-06-24 11:09:03 -04:00
parent bec56e5f4b
commit a680421281
2 changed files with 41 additions and 38 deletions

View File

@ -17,7 +17,7 @@ class Application_Model_Scheduler
private $epochNow; private $epochNow;
private $nowDT; private $nowDT;
private $user; private $user;
private $crossfadeDuration; private $crossfadeDuration;
private $checkUserPermissions = true; private $checkUserPermissions = true;
@ -40,7 +40,7 @@ class Application_Model_Scheduler
} }
$this->user = Application_Model_User::getCurrentUser(); $this->user = Application_Model_User::getCurrentUser();
$this->crossfadeDuration = Application_Model_Preference::GetDefaultCrossfadeDuration(); $this->crossfadeDuration = Application_Model_Preference::GetDefaultCrossfadeDuration();
} }
@ -200,9 +200,12 @@ class Application_Model_Scheduler
} else { } else {
$data = $this->fileInfo; $data = $this->fileInfo;
$data["id"] = $id; $data["id"] = $id;
$data["cliplength"] = Application_Model_StoredFile::getRealClipLength(
$file->getDbCuein(), $cuein = Application_Common_DateHelper::playlistTimeToSeconds($file->getDbCuein());
$file->getDbCueout()); $cueout = Application_Common_DateHelper::playlistTimeToSeconds($file->getDbCueout());
$row_length = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein);
$data["cliplength"] = $row_length;
$data["cuein"] = $file->getDbCuein(); $data["cuein"] = $file->getDbCuein();
$data["cueout"] = $file->getDbCueout(); $data["cueout"] = $file->getDbCueout();
@ -265,11 +268,11 @@ class Application_Model_Scheduler
$cuein = Application_Common_DateHelper::calculateLengthInSeconds($data["cuein"]); $cuein = Application_Common_DateHelper::calculateLengthInSeconds($data["cuein"]);
$cueout = Application_Common_DateHelper::calculateLengthInSeconds($data["cueout"]); $cueout = Application_Common_DateHelper::calculateLengthInSeconds($data["cueout"]);
$data["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein); $data["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein);
//fade is in format SS.uuuuuu //fade is in format SS.uuuuuu
$data["fadein"] = $defaultFadeIn; $data["fadein"] = $defaultFadeIn;
$data["fadeout"] = $defaultFadeOut; $data["fadeout"] = $defaultFadeOut;
$data["type"] = 0; $data["type"] = 0;
$files[] = $data; $files[] = $data;
} }
@ -324,11 +327,11 @@ class Application_Model_Scheduler
$cuein = Application_Common_DateHelper::calculateLengthInSeconds($data["cuein"]); $cuein = Application_Common_DateHelper::calculateLengthInSeconds($data["cuein"]);
$cueout = Application_Common_DateHelper::calculateLengthInSeconds($data["cueout"]); $cueout = Application_Common_DateHelper::calculateLengthInSeconds($data["cueout"]);
$data["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein); $data["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein);
//fade is in format SS.uuuuuu //fade is in format SS.uuuuuu
$data["fadein"] = $defaultFadeIn; $data["fadein"] = $defaultFadeIn;
$data["fadeout"] = $defaultFadeOut; $data["fadeout"] = $defaultFadeOut;
$data["type"] = 0; $data["type"] = 0;
$files[] = $data; $files[] = $data;
} }
@ -338,7 +341,7 @@ class Application_Model_Scheduler
return $files; return $files;
} }
/* /*
* @param DateTime startDT in UTC * @param DateTime startDT in UTC
* @param string duration * @param string duration
@ -349,18 +352,18 @@ class Application_Model_Scheduler
private function findTimeDifference($p_startDT, $p_seconds) private function findTimeDifference($p_startDT, $p_seconds)
{ {
$startEpoch = $p_startDT->format("U.u"); $startEpoch = $p_startDT->format("U.u");
//add two float numbers to 6 subsecond precision //add two float numbers to 6 subsecond precision
//DateTime::createFromFormat("U.u") will have a problem if there is no decimal in the resulting number. //DateTime::createFromFormat("U.u") will have a problem if there is no decimal in the resulting number.
$newEpoch = bcsub($startEpoch , (string) $p_seconds, 6); $newEpoch = bcsub($startEpoch , (string) $p_seconds, 6);
$dt = DateTime::createFromFormat("U.u", $newEpoch, new DateTimeZone("UTC")); $dt = DateTime::createFromFormat("U.u", $newEpoch, new DateTimeZone("UTC"));
if ($dt === false) { if ($dt === false) {
//PHP 5.3.2 problem //PHP 5.3.2 problem
$dt = DateTime::createFromFormat("U", intval($newEpoch), new DateTimeZone("UTC")); $dt = DateTime::createFromFormat("U", intval($newEpoch), new DateTimeZone("UTC"));
} }
return $dt; return $dt;
} }
@ -420,7 +423,7 @@ class Application_Model_Scheduler
return $nextDT; return $nextDT;
} }
/* /*
* @param int $showInstance * @param int $showInstance
* This function recalculates the start/end times of items in a gapless show to * This function recalculates the start/end times of items in a gapless show to
@ -499,7 +502,7 @@ class Application_Model_Scheduler
} }
/** /**
* *
* Enter description here ... * Enter description here ...
* @param $scheduleItems * @param $scheduleItems
* cc_schedule items, where the items get inserted after * cc_schedule items, where the items get inserted after
@ -882,7 +885,7 @@ class Application_Model_Scheduler
private function updateMovedItem() private function updateMovedItem()
{ {
} }
private function getInstances($instanceId) private function getInstances($instanceId)
@ -1102,7 +1105,7 @@ class Application_Model_Scheduler
} else { } else {
$removedItem->delete($this->con); $removedItem->delete($this->con);
} }
// update is_scheduled in cc_files but only if // update is_scheduled in cc_files but only if
// the file is not scheduled somewhere else // the file is not scheduled somewhere else
$fileId = $removedItem->getDbFileId(); $fileId = $removedItem->getDbFileId();

View File

@ -778,17 +778,18 @@ SQL;
foreach ($results['aaData'] as &$row) { foreach ($results['aaData'] as &$row) {
$row['id'] = intval($row['id']); $row['id'] = intval($row['id']);
$len_formatter = new LengthFormatter(
self::getRealClipLength($row["cuein"], $row["cueout"]));
$row['length'] = $len_formatter->format();
$cuein_formatter = new LengthFormatter($row["cuein"]);
$row["cuein"] = $cuein_formatter->format();
$cueout_formatter = new LengthFormatter($row["cueout"]);
$row["cueout"] = $cueout_formatter->format();
if ($row['ftype'] === "audioclip") { if ($row['ftype'] === "audioclip") {
$cuein_formatter = new LengthFormatter($row["cuein"]);
$row["cuein"] = $cuein_formatter->format();
$cueout_formatter = new LengthFormatter($row["cueout"]);
$row["cueout"] = $cueout_formatter->format();
$cuein = Application_Common_DateHelper::playlistTimeToSeconds($row["cuein"]);
$cueout = Application_Common_DateHelper::playlistTimeToSeconds($row["cueout"]);
$row_length = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein);
$formatter = new SamplerateFormatter($row['sample_rate']); $formatter = new SamplerateFormatter($row['sample_rate']);
$row['sample_rate'] = $formatter->format(); $row['sample_rate'] = $formatter->format();
@ -801,9 +802,16 @@ SQL;
// for audio preview // for audio preview
$row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION); $row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION);
} else {
$row['audioFile'] = $row['id'];
} }
else {
$row['audioFile'] = $row['id'];
$row_length = $row['length'];
}
$len_formatter = new LengthFormatter($row_length);
$row['length'] = $len_formatter->format();
//convert mtime and utime to localtime //convert mtime and utime to localtime
$row['mtime'] = new DateTime($row['mtime'], new DateTimeZone('UTC')); $row['mtime'] = new DateTime($row['mtime'], new DateTimeZone('UTC'));
@ -1347,14 +1355,6 @@ SQL;
Application_Common_Database::prepareAndExecute($sql, array(), Application_Common_Database::prepareAndExecute($sql, array(),
Application_Common_Database::EXECUTE); Application_Common_Database::EXECUTE);
} }
public static function getRealClipLength($p_cuein, $p_cueout) {
$sql = "SELECT :cueout::INTERVAL - :cuein::INTERVAL";
return Application_Common_Database::prepareAndExecute($sql, array(
':cueout' => $p_cueout,
':cuein' => $p_cuein), 'column');
}
} }
class DeleteScheduledFileException extends Exception {} class DeleteScheduledFileException extends Exception {}