modified smart block to not exceed the time limits.

This commit is contained in:
Robb Ebright 2017-03-12 22:36:36 -04:00
parent a583d8fa1e
commit ba9f7879a4
1 changed files with 12 additions and 4 deletions

View File

@ -1310,10 +1310,18 @@ SQL;
$id = $iterator->current()->getDbId();
$fileLength = $iterator->current()->getCueLength();
$length = Application_Common_DateHelper::calculateLengthInSeconds($fileLength);
$insertList[] = array('id'=>$id, 'length'=>$length);
$totalTime += $length;
$totalItems++;
// need to check to determine if the track will make the playlist exceed the totalTime before adding it
// this can be quite processor consuming so as a workaround I used the totalItems limit to prevent the
// algorithm from parsing too many items.
$projectedTime = $totalTime + $length;
if ($projectedTime > $limit['time']) {
$totalItems++;
}
else {
$insertList[] = array('id' => $id, 'length' => $length);
$totalTime += $length;
$totalItems++;
}
if ((!is_null($limit['items']) && $limit['items'] == count($insertList)) || $totalItems > 500 || $totalTime > $limit['time']) {
$isBlockFull = true;
break;