#2358 Update HTML UI playlist editor to include cue in/cue out functionality

This commit is contained in:
sebastian 2010-03-22 15:23:30 +00:00
parent 413d711511
commit 649f62e058
12 changed files with 169 additions and 110 deletions

View File

@ -653,7 +653,7 @@ $ui_fmask = array(
)
)
),
'PL.setItemPlaylength' => array(
'PL.setClipLength' => array(
'act' => array(
'element' => 'act',
'type' => 'hidden',
@ -670,11 +670,37 @@ $ui_fmask = array(
'element' => 'duration',
'type' => 'hidden'
),
'playlength' => array(
'element' => 'playlength',
'type' => 'date',
'label' => 'Playlength',
'options' => array('format' => 'His'),
'clipStart' => array(
'element' => 'clipStart',
'type' => 'select',
'label' => 'Cue in: ',
'options' => array(),
'attributes' => 'onChange="return PL_setClipLength(this)"',
'groupit' => true
),
'clipLength' => array(
'element' => 'clipLength',
'type' => 'select',
'label' => 'Length: ',
'options' => array(),
'attributes' => 'onChange="return PL_setClipLength(this)"',
'groupit' => true
),
'clipEnd' => array(
'element' => 'clipEnd',
'type' => 'select',
'label' => 'Cue out: ',
'options' => array(),
'attributes' => 'onChange="return PL_setClipLength(this)"',
'groupit' => true
),
array(
'group' => array('clipStart', 'clipLength', 'clipEnd')
),
array(
'elemnt' => 'linebreak',
'type' => 'static',
'text' => '<p></p>'
),
array(
'element' => 'cancel',
@ -691,9 +717,8 @@ $ui_fmask = array(
),
array(
'element' => 'submitter',
'type' => 'button',
'type' => 'submit',
'label' => 'Submit',
'attributes'=> array('onClick' => 'PL_checkItemPlaylength()'),
'groupit' => TRUE
),
array(

View File

@ -116,9 +116,9 @@ if (isset($_REQUEST['popup']) && is_array($_REQUEST['popup'])){
$Smarty->display('popup/PLAYLIST.arrangeItems.tpl');
break;
case "PL.setItemPlaylengthForm":
$Smarty->assign('dynform', $uiBrowser->PLAYLIST->setItemPlaylengthForm($_REQUEST['id'], $_REQUEST['elemId'], $ui_fmask['PL.setItemPlaylength']));
$Smarty->display('popup/PLAYLIST.setItemPlaylength.tpl');
case "PL.setClipLength":
$Smarty->assign('dynform', $uiBrowser->PLAYLIST->setClipLengthForm($_REQUEST['id'], $_REQUEST['elemId'], $ui_fmask['PL.setClipLength']));
$Smarty->display('popup/PLAYLIST.setClipLength.tpl');
break;
case "PL.export":

View File

@ -273,8 +273,8 @@ switch ($_REQUEST['act']) {
$uiHandler->PLAYLIST->setReload();
break;
case "PL.setItemPlaylength":
$uiHandler->PLAYLIST->setItemPlaylength($_REQUEST['elemId'], $_REQUEST['playlength']);
case "PL.setClipLength":
$uiHandler->PLAYLIST->setClipLength($_REQUEST['elemId'], $ui_fmask['PL.setClipLength']);
$uiHandler->PLAYLIST->setReload();
break;

View File

@ -39,7 +39,7 @@ if (window.attachEvent) window.attachEvent("onload", sfHover);
<li><a href="{$UI_BROWSER}?id={$START.fid}&act=PL.simpleManagement">##Edit Playlist##</a></li>
{else}
{if $PL->reportLookedPL()}
<li><a onClick="hpopup('{$UI_HANDLER}?act=PL.unlook')">##Open last Playlist##</a></li>
<li><a onClick="hpopup('{$UI_HANDLER}?act=PL.unlook')">##Reopen Playlist##</a></li>
{else}
<li><a onClick="hpopup('{$UI_HANDLER}?act=PL.create')">##New empty Playlist##</a></li>
{/if}

View File

@ -2,13 +2,11 @@ style="cursor: pointer"
onClick="return contextmenu('{$i.attrs.id}',
{if $i.type|lower == 'webstream'}
'listen', '{$i.gunid}',
{* 'PL.changeItemPlaylength', *}
'listen', '{$i.gunid}', 'PL.setCliplength',
{/if}
{if $i.type|lower == 'audioclip'}
'listen', '{$i.gunid}',
{* 'PL.changeItemPlaylength', *}
'listen', '{$i.gunid}', 'PL.setCliplength',
{/if}
'PL.removeItem'

View File

@ -18,7 +18,8 @@
<tr class="blue_head">
<td style="width: 30px"><input type="checkbox" name="all" onClick="collector_switchAll('PL')"></td>
<td style="width: 200px">##Title##</td>
<td> ##Duration##</td>
<td style="white-space: nowrap">##Clip length##</td>
<td> ##Original##</td>
<td style="width: 200px">##Artist##</td>
<td style="width: 30px;">##Type##</td>
<td style="width: 30px; border: 0">##Move##</td>
@ -26,14 +27,20 @@
<!-- end repeat after 14 columns -->
<!-- start item -->
{foreach from=$PL->getFlat($PL->activeId) key='pos' item='i'}
{*
<!-- fade information -->
<tr onClick="return contextmenu('{$i.attrs.id}', {if $i.firstInList == 1}'PL.changeFadeIn'{else}'PL.changeTransition'{/if})" style="background-color: #bbb">
<td></td>
<td colspan="5" style="border: 0; cursor: pointer">##Fade## {$i.fadein_ms|string_format:"%d"} ms</td>
</tr>
<!-- /fade information -->
*}
<tr class="{cycle values='blue1, blue2'}">
<td><input type="checkbox" class="checkbox" name="{$i.attrs.id}"/></td>
<td {include file="playlist/actionhandler.tpl"}>{$i.title}</td>
<td {include file="playlist/actionhandler.tpl"} style="text-align: right">
{assign var="_playlength" value=$i.attrs.clipLength}{niceTime in=$_playlength}
</td>
<td {include file="playlist/actionhandler.tpl"} style="text-align: right">
{assign var="_duration" value=$i.playlength}{niceTime in=$_duration}
</td>
@ -48,14 +55,17 @@
</tr>
{/foreach}
{if isset($pos)}
{*
<!-- fade information -->
<tr onClick="return contextmenu('{$i.attrs.id}', 'PL.changeFadeOut')" style="background-color: #bbb">
<td></td>
<td colspan="5" style="border: 0; cursor: pointer">##Fade## {$i.fadeout_ms|string_format:"%d"} ms</td>
</tr>
<!-- /fade information -->
*}
{else}
<tr class="{cycle values='blue1, blue2'}">
<td style="border: 0" colspan="6" align="center">##No Entry##</td>
<td style="border: 0" colspan="7" align="center">##Empty playlist##</td>
</tr>
{/if}
<!-- end item -->
@ -63,7 +73,7 @@
</table>
</div>
<div class="footer" style="width: 569px;">
<input type="button" class="button_large" onClick="collector_submit('PL', '0&popup[]=PL.changeAllTransitions', '{$UI_BROWSER}', 'chgAllTrans', 400, 150)" value="##Change Fades##" />
{* <input type="button" class="button_large" onClick="collector_submit('PL', '0&popup[]=PL.changeAllTransitions', '{$UI_BROWSER}', 'chgAllTrans', 400, 150)" value="##Change Fades##" /> *}
<input type="button" class="button_large" onClick="collector_submit('PL', 'PL.removeItem')" value="##Remove Selected##" />
<input type="button" class="button_large" onClick="collector_clearAll('PL', 'PL.removeItem')" value="##Clear Playlist##" />
</div>

View File

@ -14,7 +14,7 @@
<h1>##Playlist Editor##</h1>
<p>&nbsp;</p>
{if $PL->reportLookedPL()}
<input type="button" value="##Open last Playlist##" onClick="hpopup('{$UI_HANDLER}?act=PL.unlook')" class="button_wide">
<input type="button" value="##Reopen Playlist##" onClick="hpopup('{$UI_HANDLER}?act=PL.unlook')" class="button_wide">
{else}
<input type="button" value="##New empty Playlist##" onClick="hpopup('{$UI_HANDLER}?act=PL.create')" class="button_wide">
{/if}

View File

@ -0,0 +1,43 @@
{include file="popup/header.tpl"}
<table height="100%" width="100%">
<tr>
<td style="border: 0">
<center>
<table width="100%" height="100%">
<tr><td style="border: 0">
{include file="sub/dynForm_plain.tpl}
</td></tr>
</table>
</center>
</td>
</tr>
</table>
<script language="javascript">
{literal}
function PL_setClipLength(changed_elem)
{
var duration = parseInt(document.forms[0].elements['duration'].value);
var clipLength = parseInt(document.forms[0].elements['clipLength'].value);
var clipStart = parseInt(document.forms[0].elements['clipStart'].value);
var clipEnd = parseInt(document.forms[0].elements['clipEnd'].value);
if (changed_elem.name == 'clipLength') {
document.forms[0].elements['clipEnd'].value = clipLength + clipStart;
} else {
if (clipEnd - clipStart <=0 ) {
alert('##Remaining cliplength need to has a positive value.##');
return false;
}
document.forms[0].elements['clipLength'].value = clipEnd - clipStart;
}
}
{/literal}
</script>
</body>
</html>

View File

@ -1,45 +0,0 @@
{include file="popup/header.tpl"}
<table height="100%" width="100%">
<tr>
<td style="border: 0">
<center>
<table width="100%" height="100%">
<tr><td style="border: 0">
{include file="sub/dynForm_plain.tpl}
</td></tr>
</table>
</center>
</td>
</tr>
</table>
<script language="javascript">
{literal}
function PL_checkItemPlaylength()
{
zero = new Date('january 01 1970 00:00:00');
max = new Date('january 01 1970 '+document.forms[0].elements['duration'].value);
curr = new Date('january 01 1970 '+document.forms[0].elements['playlength[H]'].value+':'
+document.forms[0].elements['playlength[i]'].value+':'
+document.forms[0].elements['playlength[s]'].value);
if (max.getTime() != zero.getTime() && max.getTime() < curr.getTime()) {
alert('##Playlength cannot be longer than item duration##');
return false;
}
if (curr.getTime() == zero.getTime()) {
alert('##Playlength cannot be zero##');
return false;
}
document.forms[0].submit();
}
{/literal}
</script>
</body>
</html>

View File

@ -1,6 +1,6 @@
{literal}
<script type="text/javascript">
// www.jjam.de - Kontextmenü mit JavaScript - Version 15.12.2002
// www.jjam.de - Kontextmen<EFBFBD> mit JavaScript - Version 15.12.2002
// Browser detection
ie5 = (document.getElementById && document.all && document.styleSheets) ? 1 : 0;
@ -19,7 +19,7 @@ function contextmenu(param) {
var sp2 = "&nbsp;&nbsp;";
var sp5 = sp2 + sp2 + "&nbsp;"; // Leerzeichen als Abstandshalter (flexibler und code-sparender als eine aufwendige Tabellenkonstruktion) ;
var oF = "onfocus = 'if (this.blur) this.blur()'"; // Um hässlichen Linkrahmen in einigen Browsern zu vermeiden;
var oF = "onfocus = 'if (this.blur) this.blur()'"; // Um h<EFBFBD>sslichen Linkrahmen in einigen Browsern zu vermeiden;
var entry = new Array();
//contextmenuStatus = 0;
@ -38,8 +38,8 @@ function contextmenu(param) {
contextmenuHtml = contextmenuHtml + "<li><a class='contextmenu' href=\"javascript: popup('{$UI_BROWSER}?popup[]=PL.setItemPlaylengthForm&id="+param+"', 'PL.setStreamPlaylength', 400, 50)\" "+oF+">&nbsp;##Add to playlist##&nbsp;</a></li>";
break;
case "PL.changeItemPlaylength":
contextmenuHtml = contextmenuHtml + "<li><a class='contextmenu' href=\"javascript: popup('{$UI_BROWSER}?popup[]=PL.setItemPlaylengthForm&elemId="+param+"', 'PL.setItemPlaylength', 400, 50)\" "+oF+">&nbsp;##Change playlegth##&nbsp;</a></li>";
case "PL.setCliplength":
contextmenuHtml = contextmenuHtml + "<li><a class='contextmenu' href=\"javascript: popup('{$UI_BROWSER}?popup[]=PL.setClipLength&elemId="+param+"', 'PL.setClipLength', 400, 50)\" "+oF+">&nbsp;##Set clip length##&nbsp;</a></li>";
break;
case "PL.removeItem":

View File

@ -166,6 +166,7 @@ class uiPlaylist
$this->Base->_retMsg('Playlist "$1" saved.', $this->Base->getMetadataValue($tmpid, UI_MDATA_KEY_TITLE));
}
$this->Base->SCRATCHPAD->reloadMetadata();
return $this->activeId;
} // fn save
@ -240,13 +241,28 @@ class uiPlaylist
} // fn loadLookedFromPref
public function addItem($elemIds, $duration=null)
/**
* Add item to playlist
*
* @param int $elemIds
* @param array $duration
* @return unknown
*/
public function addItem($elemIds, $duration=NULL)
{
$this->changed = TRUE;
$fadeIn = null;
$fadeOut = null;
$pause = null;
$fadeIn = NULL;
$fadeOut = NULL;
$length = NULL;
$clipstart = NULL;
/*
gstreamer bug:
Warning: The clipEnd can't be bigger than ninety nine percent (99%) of the clipLength,
this means also if no clipEnd is defined it should be 00:00:00.000000 and not the clipLength.
$clipend = '00:00:00.000000';
*/
if (!$elemIds) {
if (UI_WARNING) {
$this->Base->_retMsg('No item(s) selected.');
@ -260,7 +276,7 @@ class uiPlaylist
$length = sprintf('%02d', $duration['H']).':'.sprintf('%02d', $duration['i']).':'.sprintf('%02d', $duration['s']).'.000000';
}
foreach ($elemIds as $elemId) {
$r = $this->Base->gb->addAudioClipToPlaylist($this->token, $elemId, $this->Base->sessid, $fadeIn, $fadeOut, $length, $pause);
$r = $this->Base->gb->addAudioClipToPlaylist($this->token, $elemId, $this->Base->sessid, $fadeIn, $fadeOut, $length, $clipstart, $clipend);
if (PEAR::isError($r)) {
if (UI_VERBOSE === TRUE) {
print_r($r);
@ -572,27 +588,59 @@ class uiPlaylist
} // fn changeAllTransitionsForm
public function setItemPlaylengthForm($id, $elemId, $mask)
public function setClipLengthForm($id, $elemId, $mask)
{
if (isset($elemId)) {
$mask['act']['constant'] = 'PL.setItemPlaylength';
$mask['act']['constant'] = 'PL.setClipLength';
$mask['elemId']['constant'] = $elemId;
$element = $this->getCurrElement($elemId);
$mask['playlength']['default'] = substr($element['playlength'], 0, 8);
$mask['duration']['constant'] = substr($element['duration'], 0, 8);
$playLegthS = Playlist::playlistTimeToSeconds($element['playlength']);
$clipStartS = Playlist::playlistTimeToSeconds($element['attrs']['clipStart']);
$clipEndS = Playlist::playlistTimeToSeconds($element['attrs']['clipEnd']);
$mask['duration']['constant'] = round($playLegthS);
$mask['clipLength']['default'] = round($clipEndS - $clipStartS);
$mask['clipStart']['default'] = round($clipStartS);
$mask['clipEnd']['default'] = round($clipEndS);
for ($n=0; $n<=round($playLegthS); $n++) {
$options[$n] = date('i:s', $n);
}
$mask['clipStart']['options'] = $options;
$mask['clipLength']['options'] = $options;
$mask['clipEnd']['options'] = array_reverse(array_reverse($options), true);
} else {
$mask['act']['constant'] = 'PL.addItem';
$mask['id']['constant'] = $id;
$mask['playlength']['default'] = substr($this->Base->getMetadataValue($id, UI_MDATA_KEY_DURATION), 0, 8);
$mask['clipLength']['default'] = substr($this->Base->getMetadataValue($id, UI_MDATA_KEY_DURATION), 0, 8);
$mask['duration']['constant'] = $mask['playlength']['default'];
}
$form = new HTML_QuickForm('PL_setItemPlaylengthForm', UI_STANDARD_FORM_METHOD, UI_HANDLER);
$form = new HTML_QuickForm('PL_setClipLengthForm', UI_STANDARD_FORM_METHOD, UI_HANDLER);
uiBase::parseArrayToForm($form, $mask);
$renderer = new HTML_QuickForm_Renderer_Array(true, true);
$form->accept($renderer);
return $renderer->toArray();
} // fn setItemPlaylengthForm
} // fn setClipLengthForm
function setClipLength($p_elemId, &$p_mask)
{
$form = new HTML_QuickForm('PL_setClipLengthForm', UI_STANDARD_FORM_METHOD, UI_HANDLER);
uiBase::parseArrayToForm($form, $p_mask);
if (!$form->validate()) {
return false;
}
$values = $form->exportValues();
$elem = $this->getCurrElement($values['elemId']);
if (!$elem) {
return false;
}
$clipStart = GreenBox::secondsToPlaylistTime($values['clipStart']);
$clipEnd = GreenBox::secondsToPlaylistTime($values['clipEnd']);
$this->Base->gb->changeClipLength($this->token, $p_elemId, $clipStart, $clipEnd, $this->Base->sessid);
}
public function metaDataForm($langid)

View File

@ -127,31 +127,11 @@ function S_getSecond($param)
*/
function S_niceTime($param)
{
extract($param);
if (strpos($in, '.')) {
list ($in, $lost) = explode('.', $in);
}
$in = str_replace('&nbsp;', '', $in);
$h = 0;
$i = 0;
$s = 0;
if (preg_match('/^[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}$/', $in)) {
list($h, $i, $s) = explode(':', $in);
} elseif (preg_match('/^[0-9]{1,2}:[0-9]{1,2}$/', $in)) {
list($i, $s) = explode(':', $in);
} else {
$s = $in;
}
if ((isset($all) && $all) || ($h > 0) ) {
$H = sprintf('%02d', $h).':';
} else {
$H = '&nbsp;&nbsp;&nbsp;';
}
$I = sprintf('%02d', $i).':';
$S = sprintf('%02d', $s);
return $H.$I.$S;
require_once("../../../storageServer/var/Playlist.php");
$sec = round(Playlist::playlistTimeToSeconds($param['in']));
$formatted = isset($param['all']) && $sec >= 3600 ? strftime('%H:%M:%S', $sec) : strftime('&nbsp;&nbsp;&nbsp;%M:%S', $sec);
return $formatted;
} // fn S_niceTime
?>