CC-4639: Give an option to allow smart blocks to reuse tracks if not enough tracks meet the time limit.
- done
This commit is contained in:
parent
00947f9d7e
commit
9d495ebc03
6 changed files with 99 additions and 10 deletions
|
@ -513,6 +513,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
} catch (BlockNotFoundException $e) {
|
||||
$this->playlistNotFound('block', true);
|
||||
} catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
$this->playlistUnknownError($e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -212,6 +212,14 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
|||
|
||||
}//for
|
||||
|
||||
$repeatTracks = new Zend_Form_Element_Checkbox('sp_repeat_tracks');
|
||||
$repeatTracks->setDecorators(array('viewHelper'))
|
||||
->setLabel('Allow Repeat Tracks:');
|
||||
if (isset($storedCrit["repeat_tracks"])) {
|
||||
$repeatTracks->setChecked($storedCrit["repeat_tracks"]["value"] == 1?true:false);
|
||||
}
|
||||
$this->addElement($repeatTracks);
|
||||
|
||||
$limit = new Zend_Form_Element_Select('sp_limit_options');
|
||||
$limit->setAttrib('class', 'sp_input_select')
|
||||
->setDecorators(array('viewHelper'))
|
||||
|
|
|
@ -1093,6 +1093,14 @@ SQL;
|
|||
->setDbValue($p_criteriaData['etc']['sp_limit_value'])
|
||||
->setDbBlockId($this->id)
|
||||
->save();
|
||||
|
||||
// insert repeate track option
|
||||
$qry = new CcBlockcriteria();
|
||||
$qry->setDbCriteria("repeat_tracks")
|
||||
->setDbModifier("N/A")
|
||||
->setDbValue($p_criteriaData['etc']['sp_repeat_tracks'])
|
||||
->setDbBlockId($this->id)
|
||||
->save();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1105,7 +1113,7 @@ SQL;
|
|||
$this->saveSmartBlockCriteria($p_criteria);
|
||||
$insertList = $this->getListOfFilesUnderLimit();
|
||||
$this->deleteAllFilesFromBlock();
|
||||
$this->addAudioClips(array_keys($insertList));
|
||||
$this->addAudioClips(array_values($insertList));
|
||||
// update length in playlist contents.
|
||||
$this->updateBlockLengthInAllPlaylist();
|
||||
|
||||
|
@ -1134,6 +1142,7 @@ SQL;
|
|||
$info = $this->getListofFilesMeetCriteria();
|
||||
$files = $info['files'];
|
||||
$limit = $info['limit'];
|
||||
$repeat = $info['repeat_tracks'];
|
||||
|
||||
$insertList = array();
|
||||
$totalTime = 0;
|
||||
|
@ -1142,14 +1151,40 @@ SQL;
|
|||
// this moves the pointer to the first element in the collection
|
||||
$files->getFirst();
|
||||
$iterator = $files->getIterator();
|
||||
while ($iterator->valid() && $totalTime < $limit['time']) {
|
||||
|
||||
$isBlockFull = false;
|
||||
|
||||
while ($iterator->valid()) {
|
||||
$id = $iterator->current()->getDbId();
|
||||
$length = Application_Common_DateHelper::calculateLengthInSeconds($iterator->current()->getDbLength());
|
||||
$insertList[$id] = $length;
|
||||
$insertList[] = $id;
|
||||
$totalTime += $length;
|
||||
$totalItems++;
|
||||
|
||||
if ((!is_null($limit['items']) && $limit['items'] == count($insertList)) || $totalItems > 500) {
|
||||
if ((!is_null($limit['items']) && $limit['items'] == count($insertList)) || $totalItems > 500 || $totalTime > $limit['time']) {
|
||||
$isBlockFull = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$iterator->next();
|
||||
}
|
||||
|
||||
// if block is not full and reapeat_track is check, fill up more
|
||||
while (!$isBlockFull && $repeat == 1) {
|
||||
if (!$iterator->valid()) {
|
||||
$iterator->closeCursor();
|
||||
$info = $this->getListofFilesMeetCriteria();
|
||||
$files = $info['files'];
|
||||
$files->getFirst();
|
||||
$iterator = $files->getIterator();
|
||||
}
|
||||
$id = $iterator->current()->getDbId();
|
||||
$length = Application_Common_DateHelper::calculateLengthInSeconds($iterator->current()->getDbLength());
|
||||
$insertList[] = $id;
|
||||
$totalTime += $length;
|
||||
$totalItems++;
|
||||
|
||||
if ((!is_null($limit['items']) && $limit['items'] == count($insertList)) || $totalItems > 500 || $totalTime > $limit['time']) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1202,6 +1237,8 @@ SQL;
|
|||
|
||||
if ($criteria == "limit") {
|
||||
$storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
|
||||
} else if($criteria == "repeat_tracks") {
|
||||
$storedCrit["repeat_tracks"] = array("value"=>$value);
|
||||
} else {
|
||||
$storedCrit["crit"][$criteria][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra, "display_name"=>$criteriaOptions[$criteria]);
|
||||
}
|
||||
|
@ -1317,6 +1354,7 @@ SQL;
|
|||
}
|
||||
// construct limit restriction
|
||||
$limits = array();
|
||||
|
||||
if (isset($storedCrit['limit'])) {
|
||||
if ($storedCrit['limit']['modifier'] == "items") {
|
||||
$limits['time'] = 1440 * 60;
|
||||
|
@ -1328,10 +1366,16 @@ SQL;
|
|||
$limits['items'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
$repeatTracks = 0;
|
||||
if (isset($storedCrit['repeat_tracks'])) {
|
||||
$repeatTracks = $storedCrit['repeat_tracks']['value'];
|
||||
}
|
||||
|
||||
try {
|
||||
$out = $qry->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find();
|
||||
|
||||
return array("files"=>$out, "limit"=>$limits, "count"=>$out->count());
|
||||
return array("files"=>$out, "limit"=>$limits, "repeat_tracks"=> $repeatTracks, "count"=>$out->count());
|
||||
} catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
}
|
||||
|
|
|
@ -59,6 +59,20 @@
|
|||
<br />
|
||||
</dd>
|
||||
|
||||
<dd id='sp_repeate_tracks-element'>
|
||||
<span class='sp_text_font'><?php echo $this->element->getElement('sp_repeat_tracks')->getLabel() ?></span>
|
||||
<span class='repeat_tracks_help_icon'></span>
|
||||
<?php echo $this->element->getElement('sp_repeat_tracks')?>
|
||||
<?php if($this->element->getElement("sp_repeat_tracks")->hasErrors()) : ?>
|
||||
<?php foreach($this->element->getElement("sp_repeat_tracks")->getMessages() as $error): ?>
|
||||
<span class='errors sp-errors'>
|
||||
<?php echo $error; ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<br />
|
||||
</dd>
|
||||
|
||||
<dd id='sp_limit-element'>
|
||||
<span class='sp_text_font'><?php echo $this->element->getElement('sp_limit_value')->getLabel() ?></span>
|
||||
<?php echo $this->element->getElement('sp_limit_value')?>
|
||||
|
|
|
@ -105,7 +105,7 @@ select {
|
|||
}
|
||||
|
||||
.airtime_auth_help_icon, .custom_auth_help_icon, .stream_username_help_icon,
|
||||
.playlist_type_help_icon, .master_username_help_icon {
|
||||
.playlist_type_help_icon, .master_username_help_icon, .repeat_tracks_help_icon{
|
||||
cursor: help;
|
||||
position: relative;
|
||||
display:inline-block; zoom:1;
|
||||
|
|
|
@ -384,6 +384,28 @@ function setupUI() {
|
|||
at: "right center"
|
||||
},
|
||||
});
|
||||
|
||||
$(".repeat_tracks_help_icon").qtip({
|
||||
content: {
|
||||
text: "If your criteria is too strict, Airtime may not be able to fill up the desired smart block length." +
|
||||
" Hence, if you check this option, tracks will be used more than once."
|
||||
},
|
||||
hide: {
|
||||
delay: 500,
|
||||
fixed: true
|
||||
},
|
||||
style: {
|
||||
border: {
|
||||
width: 0,
|
||||
radius: 4
|
||||
},
|
||||
classes: "ui-tooltip-dark ui-tooltip-rounded"
|
||||
},
|
||||
position: {
|
||||
my: "left bottom",
|
||||
at: "right center"
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function enableAndShowExtraField(valEle, index) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue