Merge branch 'master' of dev.sourcefabric.org:campcaster

This commit is contained in:
paul.baranowski 2010-09-27 17:06:12 -04:00
commit c5d1faf0f9
6 changed files with 287 additions and 175 deletions

View File

@ -48,8 +48,9 @@
.pl_head span {
display:inline-block;
vertical-align: top;
padding-top: 0.5em;
vertical-align: middle;
padding-top: 0.2em;
padding-bottom: 0.2em;
font-weight: bold;
}
@ -66,49 +67,64 @@
.pl_row span {
display:inline-block;
vertical-align: middle;
padding: 0.2em 0;
padding-top: 0.2em;
padding-bottom: 0.2em;
}
.pl_input{
width: 5%;
width: 25px;
}
.pl_title{
width: 21%;
width: 160px;
padding-right: 10px;
}
.pl_artist{
width: 20%;
width: 140px;
padding-right: 10px;
}
.pl_length{
width: 11%;
width: 100px;
}
.pl_cue_in{
width: 11%;
width: 100px;
}
.pl_cue_out{
width: 11%;
width: 100px;
}
.pl_playlength{
width: 11%;
width: 100px;
}
.pl_fade_in{
padding: 0.2em 2em;
border-top: thin ridge black;
border-top: thin solid #999999;
background-color: #cccccc;
}
.pl_fade_in span{
display: inline-block;
width: 60px;
padding-right: 5px;
}
.pl_fade_out{
padding-left: 2em;
background-color: #cccccc;
padding: 0.2em 2em;
}
.pl_fade_out span{
display: inline-block;
width: 60px;
padding-right: 5px;
}
.pl_time{
cursor: pointer;
}

View File

@ -48,18 +48,27 @@ $(document).ready(function() {
);
});
function removeTextInput(){
function removeCueInput(){
var span = $(this).parent();
var pos = span.parent().attr('id').split("_").pop();
var cueIn, cueOut;
var regExpr = new RegExp("^\\d{2}[:]\\d{2}[:]\\d{2}([.]\\d{1,4})?$");
var regExpr = new RegExp("^\\d{2}[:]\\d{2}[:]\\d{2}([.]\\d{1,6})?$");
var oldValue = $("#pl_tmp_time").val();
var newValue = $(this).val().trim();
if(span.hasClass('pl_cue_in')){
if(newValue === "")
newValue = '00:00:00';
cueIn = newValue;
}
else if(span.hasClass('pl_cue_out')){
cueOut = newValue;
}
//test that input is a time.
if (!regExpr.test(newValue)) {
if (newValue!=="" && !regExpr.test(newValue)) {
span.empty();
span.append(oldValue);
span.click(addTextInput);
@ -67,13 +76,6 @@ $(document).ready(function() {
return;
}
if(span.hasClass('pl_cue_in')){
cueIn = $(this).val();
}
else if(span.hasClass('pl_cue_out')){
cueOut = $(this).val();
}
$.post("ui_handler.php",
{ 'act': 'PL.setClipLength', 'pos': pos, 'cueIn': cueIn, 'cueOut': cueOut },
@ -92,24 +94,99 @@ $(document).ready(function() {
span.click(addTextInput);
alert(data.error);
}
else if(data.type==="cue"){
span = li.find(".pl_playlength");
span.empty();
span.append(data.cliplength);
span = li.find(".pl_playlength");
span.empty();
span.append(data.cliplength);
span = $(".pl_duration");
span.empty();
span.append(data.length);
if(data.cueIn){
span = li.find(".pl_cue_in");
span.empty();
span.append(data.cueIn);
span.click(addTextInput);
}
if(data.cueOut){
span = li.find(".pl_cue_out");
span.empty();
span.append(data.cueOut);
span.click(addTextInput);
}
span = li.find(".pl_fade_in").find(".pl_time");
span.empty();
span.append(data.fadeIn);
span = li.find(".pl_fade_out").find(".pl_time");
span.empty();
span.append(data.fadeOut);
},
"json"
);
}
function removeFadeInput(){
var span = $(this).parent();
var pos = span.parent().parent().attr('id').split("_").pop();
var fadeIn, fadeOut;
var regExpr = new RegExp("^\\d{2}[:]\\d{2}[:]\\d{2}([.]\\d{1,6})?$");
var oldValue = $("#pl_tmp_time").val();
var newValue = $(this).val().trim();
if(newValue === "")
newValue = '00:00:00';
if(span.parent().hasClass('pl_fade_in')){
fadeIn = newValue;
}
else if(span.parent().hasClass('pl_fade_out')){
fadeOut = newValue;
}
//test that input is a time.
if (!regExpr.test(newValue)) {
span.empty();
span.append(oldValue);
span.click(addTextInput);
alert("please put in a time '00:00:00 (.0000)'");
return;
}
$.post("ui_handler.php",
{ 'act': 'PL.setFadeLength', 'pos': pos, 'fadeIn': fadeIn, 'fadeOut': fadeOut },
function(data){
var li, span;
li = $("#pl_"+pos);
if(data.error){
var hidden = $("#pl_tmp_time");
var time = hidden.val();
if(data.cueIn){
span = li.find(".pl_cue_in");
span.empty();
span.append(data.cueIn);
span.click(addTextInput);
}
if(data.cueOut){
span = li.find(".pl_cue_out");
span.empty();
span.append(data.cueOut);
span.click(addTextInput);
}
span = hidden.parent();
span.empty();
span.append(time);
span.click(addTextInput);
alert(data.error);
}
if(data.fadeIn){
span = li.find(".pl_fade_in").find(".pl_time");
span.empty();
span.append(data.fadeIn);
span.click(addTextInput);
}
if(data.fadeOut){
span = li.find(".pl_fade_out").find(".pl_time");
span.empty();
span.append(data.fadeOut);
span.click(addTextInput);
}
},
"json"
@ -118,7 +195,7 @@ $(document).ready(function() {
function addTextInput(){
var time = $(this).text().trim();
var input = $("<input type='text' value="+time+" size='10' maxlength='13'/>");
var input = $("<input type='text' value="+time+" size='10' maxlength='15'/>");
//Firefox seems to have problems losing focus otherwise, Chrome is fine.
$(":input").blur();
@ -126,7 +203,14 @@ $(document).ready(function() {
$(this).append(input);
input.focus();
input.blur(removeTextInput);
if($(this).hasClass('pl_cue_in') || $(this).hasClass('pl_cue_out')) {
input.blur(removeCueInput);
}
else if($(this).parent().hasClass('pl_fade_in') || $(this).parent().hasClass('pl_fade_out')){
input.blur(removeFadeInput);
}
input.keypress(function(ev){
//don't want enter to submit.
if (ev.keyCode == '13') {

View File

@ -325,6 +325,10 @@ switch ($_REQUEST['act']) {
case "PL.setClipLength":
$uiHandler->PLAYLIST->setClipLength($_REQUEST['pos'], $_REQUEST['cueIn'], $_REQUEST['cueOut']);
break;
case "PL.setFadeLength":
$uiHandler->PLAYLIST->setFadeLength($_REQUEST['pos'], $_REQUEST['fadeIn'], $_REQUEST['fadeOut']);
break;
case "PL.removeItem":
$uiHandler->PLAYLIST->removeItem($_REQUEST['id']);

View File

@ -2,7 +2,7 @@
<div class="pl_container" >
<div class="pl_header">
<div class="pl_header_left"><span>##Playlist Editor## </span></div>
<div class="pl_header_right"><span>{$PL->title}</span><span>{niceTime in=$PL->duration} </span></div>
<div class="pl_header_right"><span>{$PL->title}</span><span class="pl_duration">{$PL->duration} </span></div>
</div>
<div class="pl_contents">
<form name="PL">
@ -19,29 +19,29 @@
<ul id="pl_sortable">
{foreach from=$PL->getActiveArr($PL->activeId) key='pos' item='i'}
<li class="pl_row" id="pl_{$pos}">
<div class="pl_fade_in">fade in: {$i.fadein}</div>
<span class="pl_input">
<input type="checkbox" class="checkbox" name="{$pos}"/>
</span>
<span class="pl_title">
{$i.track_title}
</span>
<span class="pl_artist">
{$i.artist_name}
</span>
<span class="pl_length" >
{$i.length}
</span>
<span class="pl_cue_in pl_time">
{$i.cuein}
</span>
<span class="pl_cue_out pl_time">
{$i.cueout}
</span>
<span class="pl_playlength">
{$i.cliplength}
</span>
<div class="pl_fade_out">fade out: {$i.fadeout}</div>
<div class="pl_fade_in"><span>Fade in: </span><span class="pl_time">{$i.fadein}</span></div>
<span class="pl_input">
<input type="checkbox" class="checkbox" name="{$pos}"/>
</span>
<span class="pl_title">
{$i.track_title}
</span>
<span class="pl_artist">
{$i.artist_name}
</span>
<span class="pl_length" >
{$i.length}
</span>
<span class="pl_cue_in pl_time">
{$i.cuein}
</span>
<span class="pl_cue_out pl_time">
{$i.cueout}
</span>
<span class="pl_playlength">
{$i.cliplength}
</span>
<div class="pl_fade_out"><span>Fade out: </span><span class="pl_time">{$i.fadeout}</span></div>
</li>
{/foreach}
{if is_null($pos)}

View File

@ -302,74 +302,6 @@ class uiPlaylist
return $plid;
} // fn create
public function changeTransition($id, $type, $duration)
{
$pause = $pause;
$xfade = Playlist::secondsToPlaylistTime($duration/1000);
if ($id) {
// just change fade between 2 clips
$curr = $this->getCurrElement($id);
$prev = $this->getPrevElement($id);
$next = $this->getNextElement($id);
switch ($type) {
case "fadeX":
$item[$prev['attrs']['id']] =
array(UI_PL_ELEM_FADEIN => Playlist::secondsToPlaylistTime($prev[UI_PL_ELEM_FADEIN]),
UI_PL_ELEM_FADEOUT => $xfade
);
$item[$id] = array(UI_PL_ELEM_FADEIN => $xfade,
UI_PL_ELEM_FADEOUT => Playlist::secondsToPlaylistTime($curr[UI_PL_ELEM_FADEOUT])
);
break;
case "pause":
$item[$prev['attrs']['id']] =
array(UI_PL_ELEM_FADEIN => Playlist::secondsToPlaylistTime($prev[UI_PL_ELEM_FADEIN]),
UI_PL_ELEM_FADEOUT => $pause
);
$item[$id] = array(UI_PL_ELEM_FADEIN => $pause,
UI_PL_ELEM_FADEOUT => Playlist::secondsToPlaylistTime($curr[UI_PL_ELEM_FADEOUT])
);
break;
case "fadeIn":
$item[$id] = array(UI_PL_ELEM_FADEIN => $xfade,
UI_PL_ELEM_FADEOUT => Playlist::secondsToPlaylistTime($curr[UI_PL_ELEM_FADEOUT])
);
break;
case "fadeOut":
$item[$id] = array(UI_PL_ELEM_FADEIN => Playlist::secondsToPlaylistTime($curr[UI_PL_ELEM_FADEIN]),
UI_PL_ELEM_FADEOUT => $xfade
);
break;
}
foreach ($item as $i=>$val) {
$r = $this->Base->gb->changeFadeInfo($this->token, $i, $val[UI_PL_ELEM_FADEIN], $val[UI_PL_ELEM_FADEOUT], $this->Base->sessid);
if (PEAR::isError($r)) {
if (UI_VERBOSE === TRUE) {
print_r($r);
}
$this->Base->_retMsg('Changing fade information failed.');
return FALSE;
}
}
} else {
// change fade of all clips
foreach ($this->getFlat($this->activeId) as $v) {
$r = $this->Base->gb->changeFadeInfo($this->token, $v['attrs']['id'], $type==='pause'?$pause:$xfade, $type==='pause'?$pause:$xfade, $this->Base->sessid);
if (PEAR::isError($r)) {
if (UI_VERBOSE === TRUE) {
print_r($r);
}
$this->Base->_retMsg('Changing fade information failed.');
return FALSE;
}
}
}
return TRUE;
} // fn changeTransition
public function moveItem($oldPos, $newPos)
{
$response = array();
@ -388,30 +320,27 @@ class uiPlaylist
} // fn moveItem
public function changeTransitionForm($id, $type, $mask)
{
} // fn changeTransitionForm
public function changeAllTransitionsForm($mask)
{
} // fn changeAllTransitionsForm
function setClipLength($pos, $cueIn, $cueOut)
public function setClipLength($pos, $cueIn, $cueOut)
{
$response = array();
$response["type"] = "cue";
$response["pos"] = $pos;
$res = $this->Base->gb->changeClipLength($this->activeId, $pos, $cueIn, $cueOut);
$response = array_merge($response, $res);
$response = $res;
die(json_encode($response));
}
public function setFadeLength($pos, $fadeIn, $fadeOut)
{
$response = array();
$res = $this->Base->gb->changeFadeInfo($this->activeId, $pos, $fadeIn, $fadeOut);
$response = $res;
die(json_encode($response));
} // fn setFade
public function metaDataForm($langid)

View File

@ -608,16 +608,59 @@ class Playlist {
public function changeFadeInfo($pos, $fadeIn, $fadeOut)
{
global $CC_CONFIG, $CC_DBC;
$sql = "UPDATE ".$CC_CONFIG['playListContentsTable']. " SET fadein='{$fadeIn}', fadeout='{$fadeOut}' " .
"WHERE playlist_id='{$this->getId()}' AND position='{$pos}'";
$errArray= array();
if(is_null($pos) || $pos < 0 || $pos >= $this->getNextPos()) {
$errArray["error"]="Invalid position.";
return $errArray;
}
$sql = $sql = "SELECT cliplength
FROM cc_playlistcontents WHERE playlist_id='{$this->getId()}' AND position='{$pos}'";
$clipLength = $CC_DBC->getOne($sql);
if(!is_null($fadeIn) && !is_null($fadeOut)) {
if(Playlist::playlistTimeToSeconds($fadeIn) > Playlist::playlistTimeToSeconds($clipLength)) {
$errArray["error"]="Fade In can't be larger than overall playlength.";
return $errArray;
}
if(Playlist::playlistTimeToSeconds($fadeOut) > Playlist::playlistTimeToSeconds($clipLength)) {
$errArray["error"]="Fade Out can't be larger than overall playlength.";
return $errArray;
}
$sql = "UPDATE ".$CC_CONFIG['playListContentsTable']. " SET fadein='{$fadeIn}', fadeout='{$fadeOut}' " .
"WHERE playlist_id='{$this->getId()}' AND position='{$pos}'";
}
else if(!is_null($fadeIn)) {
if(Playlist::playlistTimeToSeconds($fadeIn) > Playlist::playlistTimeToSeconds($clipLength)) {
$errArray["error"]="Fade In can't be larger than overall playlength.";
return $errArray;
}
$sql = "UPDATE ".$CC_CONFIG['playListContentsTable']. " SET fadein='{$fadeIn}' " .
"WHERE playlist_id='{$this->getId()}' AND position='{$pos}'";
}
else if(!is_null($fadeOut)){
if(Playlist::playlistTimeToSeconds($fadeOut) > Playlist::playlistTimeToSeconds($clipLength)) {
$errArray["error"]="Fade Out can't be larger than overall playlength.";
return $errArray;
}
$sql = "UPDATE ".$CC_CONFIG['playListContentsTable']. " SET fadeout='{$fadeOut}' " .
"WHERE playlist_id='{$this->getId()}' AND position='{$pos}'";
}
$res = $CC_DBC->query($sql);
if (PEAR::isError($res)) {
return $res;
$errArray["error"] =$res->getMessage();
return $errArray;
}
return TRUE;
return array("fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut);
}
/**
@ -634,36 +677,40 @@ class Playlist {
public function changeClipLength($pos, $cueIn, $cueOut)
{
global $CC_CONFIG, $CC_DBC;
$oldCueIn;
$oldCueOut;
$errArray= array();
if(is_null($pos) || is_null($cueIn) && is_null($cueOut))
return FALSE;
if(is_null($cueIn) && is_null($cueOut)) {
$errArray["error"]="Cue in and cue out are null.";
return $errArray;
}
if($pos < 0 || $pos >= $this->getNextPos())
return FALSE;
if(is_null($pos) || $pos < 0 || $pos >= $this->getNextPos()) {
$errArray["error"]="Invalid position.";
return $errArray;
}
$sql = $sql = "SELECT length AS original_length
$sql = $sql = "SELECT length AS original_length, cuein, cueout, fadein, fadeout
FROM cc_playlistcontents C JOIN cc_files F ON C.file_id = F.id
WHERE C.playlist_id='{$this->getId()}' AND position='{$pos}'";
$origLength = $CC_DBC->getOne($sql);
$sql = "SELECT cuein, cueout FROM ".$CC_CONFIG['playListContentsTable']."
WHERE playlist_id='{$this->getId()}' AND position='{$pos}'";
$res = $CC_DBC->getRow($sql);
$origLength = $res['original_length'];
$oldCueIn = $res['cuein'];
$oldCueOut = $res['cueout'];
$fadeIn = $res['fadein'];
$fadeOut = $res['fadeout'];
if(!is_null($cueIn) && !is_null($cueOut)){
if($cueIn > $cueOut) {
$errArray["error"]="Can't set cue in to be larger than cue out.";
if($cueOut === ""){
$cueOut = $origLength;
}
if(Playlist::playlistTimeToSeconds($cueIn) > Playlist::playlistTimeToSeconds($cueOut)) {
$errArray["error"]= "Can't set cue in to be larger than cue out.";
return $errArray;
}
if($cueOut > $origLength){
$errArray["error"] ="Can't set cue out to be greater than file length.";
if(Playlist::playlistTimeToSeconds($cueOut) > Playlist::playlistTimeToSeconds($origLength)){
$errArray["error"] = "Can't set cue out to be greater than file length.";
return $errArray;
}
@ -672,13 +719,13 @@ class Playlist {
$sql = "UPDATE ".$CC_CONFIG['playListContentsTable'].
" SET cuein='{$cueIn}', cueout='{$cueOut}', ".
"cliplength=(cliplength + interval '{$oldCueIn}' - interval '{$cueIn}' - interval '{$oldCueOut}' + interval '{$cueOut}') " .
"cliplength=(interval '{$cueOut}' - interval '{$cueIn}') " .
"WHERE playlist_id='{$this->getId()}' AND position='{$pos}'";
}
else if(!is_null($cueIn)) {
if($cueIn > $oldCueOut) {
if(Playlist::playlistTimeToSeconds($cueIn) > Playlist::playlistTimeToSeconds($oldCueOut)) {
$errArray["error"] = "Can't set cue in to be larger than cue out.";
return $errArray;
}
@ -686,17 +733,21 @@ class Playlist {
$cueIn = pg_escape_string($cueIn);
$sql = "UPDATE ".$CC_CONFIG['playListContentsTable'].
" SET cuein='{$cueIn}', cliplength=(cliplength + interval '{$oldCueIn}' - interval '{$cueIn}') " .
" SET cuein='{$cueIn}', cliplength=(interval '{$oldCueOut}' - interval '{$cueIn}') " .
"WHERE playlist_id='{$this->getId()}' AND position='{$pos}'";
}
else if(!is_null($cueOut)) {
if($cueOut < $oldCueIn) {
if($cueOut === ""){
$cueOut = $origLength;
}
if(Playlist::playlistTimeToSeconds($cueOut) < Playlist::playlistTimeToSeconds($oldCueIn)) {
$errArray["error"] ="Can't set cue out to be smaller than cue in.";
return $errArray;
}
if($cueOut > $origLength){
if(Playlist::playlistTimeToSeconds($cueOut) > Playlist::playlistTimeToSeconds($origLength)){
$errArray["error"] ="Can't set cue out to be greater than file length.";
return $errArray;
}
@ -704,7 +755,7 @@ class Playlist {
$cueOut = pg_escape_string($cueOut);
$sql = "UPDATE ".$CC_CONFIG['playListContentsTable'].
" SET cueout='{$cueOut}', cliplength=(cliplength - interval '{$oldCueOut}' + interval '{$cueOut}') " .
" SET cueout='{$cueOut}', cliplength=(interval '{$cueOut}' - interval '{$oldCueIn}') " .
"WHERE playlist_id='{$this->getId()}' AND position='{$pos}'";
}
@ -717,8 +768,36 @@ class Playlist {
$sql = "SELECT cliplength FROM ".$CC_CONFIG['playListContentsTable']."
WHERE playlist_id='{$this->getId()}' AND position='{$pos}'";
$cliplength = $CC_DBC->getOne($sql);
if(Playlist::playlistTimeToSeconds($fadeIn) > Playlist::playlistTimeToSeconds($cliplength)){
$fadeIn = $cliplength;
$sql = "UPDATE ".$CC_CONFIG['playListContentsTable'].
" SET fadein='{$fadeIn}' " .
"WHERE playlist_id='{$this->getId()}' AND position='{$pos}'";
$res = $CC_DBC->query($sql);
if (PEAR::isError($res)) {
$errArray["error"] =$res->getMessage();
return $errArray;
}
}
if(Playlist::playlistTimeToSeconds($fadeOut) > Playlist::playlistTimeToSeconds($cliplength)){
$fadeOut = $cliplength;
$sql = "UPDATE ".$CC_CONFIG['playListContentsTable'].
" SET fadeout='{$fadeOut}' " .
"WHERE playlist_id='{$this->getId()}' AND position='{$pos}'";
$res = $CC_DBC->query($sql);
if (PEAR::isError($res)) {
$errArray["error"] =$res->getMessage();
return $errArray;
}
}
return array("cliplength"=>$cliplength, "cueIn"=>$cueIn, "cueOut"=>$cueOut);
return array("cliplength"=>$cliplength, "cueIn"=>$cueIn, "cueOut"=>$cueOut, "length"=>$this->getLength(),
"fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut);
}
/**