CC-3174 : showbuilder/library

playlist fades are working again, still need more error checking to be done.
This commit is contained in:
Naomi Aro 2012-02-05 23:38:12 +01:00
parent fbec92cb0d
commit 16863ee95e
7 changed files with 105 additions and 74 deletions

View File

@ -74,7 +74,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
//scripts for now playing bar //scripts for now playing bar
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/helperfunctions.js','text/javascript'); $view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/helperfunctions.js','text/javascript');
//$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/playlist.js','text/javascript'); $view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/playlist.js','text/javascript');
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/versiontooltip.js','text/javascript'); $view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/versiontooltip.js','text/javascript');
$view->headScript()->appendFile($baseUrl.'/js/airtime/common/common.js','text/javascript'); $view->headScript()->appendFile($baseUrl.'/js/airtime/common/common.js','text/javascript');

View File

@ -16,6 +16,7 @@ class PlaylistController extends Zend_Controller_Action
->addActionContext('edit', 'json') ->addActionContext('edit', 'json')
->addActionContext('delete', 'json') ->addActionContext('delete', 'json')
->addActionContext('set-playlist-fades', 'json') ->addActionContext('set-playlist-fades', 'json')
->addActionContext('get-playlist-fades', 'json')
->addActionContext('set-playlist-name', 'json') ->addActionContext('set-playlist-name', 'json')
->addActionContext('set-playlist-description', 'json') ->addActionContext('set-playlist-description', 'json')
->initContext(); ->initContext();
@ -265,52 +266,73 @@ class PlaylistController extends Zend_Controller_Action
public function setFadeAction() public function setFadeAction()
{ {
$pos = $this->_getParam('pos'); $id = $this->_getParam('id');
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
$fadeIn = $this->_getParam('fadeIn', null); $fadeIn = $this->_getParam('fadeIn', null);
$fadeOut = $this->_getParam('fadeOut', null); $fadeOut = $this->_getParam('fadeOut', null);
$response = $pl->changeFadeInfo($pos, $fadeIn, $fadeOut); try {
$pl = $this->getPlaylist();
$response = $pl->changeFadeInfo($id, $fadeIn, $fadeOut);
$this->view->response = $response; $this->view->response = $response;
if(!isset($response["error"])) { if (!isset($response["error"])) {
$this->createUpdateResponse($pl); $this->createUpdateResponse($pl);
}
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
}
}
public function getPlaylistFadesAction()
{
try {
$pl = $this->getPlaylist();
$fades = $pl->getFadeInfo(0);
$this->view->fadeIn = $fades[0];
$fades = $pl->getFadeInfo($pl->getSize()-1);
$this->view->fadeOut = $fades[1];
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
} }
} }
public function setPlaylistFadesAction() public function setPlaylistFadesAction()
{ {
$request = $this->getRequest(); $fadeIn = $this->_getParam('fadeIn', null);
$pl = $this->getPlaylist(); $fadeOut = $this->_getParam('fadeOut', null);
if($pl === false){
$this->view->playlist_error = true; try {
return false; $pl = $this->getPlaylist();
$pl->setPlaylistfades($fadeIn, $fadeOut);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
} }
if($request->isPost()) {
$fadeIn = $this->_getParam('fadeIn', null);
$fadeOut = $this->_getParam('fadeOut', null);
if($fadeIn)
$response = $pl->changeFadeInfo(0, $fadeIn, $fadeOut);
else if($fadeOut)
$response = $pl->changeFadeInfo($pl->getSize(), $fadeIn, $fadeOut);
$this->view->response = $response;
return;
}
$fades = $pl->getFadeInfo(0);
$this->view->fadeIn = $fades[0];
$fades = $pl->getFadeInfo($pl->getSize());
$this->view->fadeOut = $fades[1];
} }
public function setPlaylistNameAction() public function setPlaylistNameAction()

View File

@ -389,6 +389,8 @@ class Application_Model_Playlist {
public function getFadeInfo($pos) { public function getFadeInfo($pos) {
Logging::log("Getting fade info for pos {$pos}");
$row = CcPlaylistcontentsQuery::create() $row = CcPlaylistcontentsQuery::create()
->joinWith(CcFilesPeer::OM_CLASS) ->joinWith(CcFilesPeer::OM_CLASS)
->filterByDbPlaylistId($this->id) ->filterByDbPlaylistId($this->id)
@ -412,21 +414,18 @@ class Application_Model_Playlist {
* new value in ss.ssssss or extent format * new value in ss.ssssss or extent format
* @return boolean * @return boolean
*/ */
public function changeFadeInfo($pos, $fadeIn, $fadeOut) public function changeFadeInfo($id, $fadeIn, $fadeOut)
{ {
$errArray= array(); $errArray= array();
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME); $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
if(is_null($pos) || $pos < 0 || $pos >= $this->getNextPos()) { $row = CcPlaylistcontentsQuery::create()->findPK($id);
$errArray["error"]="Invalid position.";
if (is_null($row)) {
$errArray["error"]="Playlist item does not exist.";
return $errArray; return $errArray;
} }
$row = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id)
->filterByDbPosition($pos)
->findOne();
$clipLength = $row->getDbCliplength(); $clipLength = $row->getDbCliplength();
if(!is_null($fadeIn)) { if(!is_null($fadeIn)) {
@ -457,6 +456,28 @@ class Application_Model_Playlist {
return array("fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut); return array("fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut);
} }
public function setPlaylistfades($fadein, $fadeout) {
if (isset($fadein)) {
Logging::log("Setting playlist fade in {$fadein}");
$row = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id)
->filterByDbPosition(0)
->findOne();
$this->changeFadeInfo($row->getDbId(), $fadein, null);
}
if (isset($fadeout)) {
$row = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id)
->filterByDbPosition($this->getSize()-1)
->findOne();
$this->changeFadeInfo($row->getDbId(), null, $fadeout);
}
}
/** /**
* Change cueIn/cueOut values for playlist element * Change cueIn/cueOut values for playlist element
* *

View File

@ -1,11 +1,11 @@
<dl id="spl_editor" class="inline-list"> <dl id="spl_editor" class="inline-list">
<dt>Fade out:</dt> <dt>Fade out:</dt>
<dd id="spl_fade_out_<?php echo $this->pos; ?>" class="spl_fade_out"> <dd id="spl_fade_out_<?php echo $this->item1; ?>" class="spl_fade_out">
<span contenteditable="true" class="spl_text_input"><?php echo $this->fadeOut; ?></span> <span contenteditable="true" class="spl_text_input"><?php echo $this->fadeOut; ?></span>
</dd> </dd>
<dd class="edit-error"></dd> <dd class="edit-error"></dd>
<dt>Fade in:</dt> <dt>Fade in:</dt>
<dd id="spl_fade_in_<?php echo $this->pos + 1; ?>" class="spl_fade_in"> <dd id="spl_fade_in_<?php echo $this->item2; ?>" class="spl_fade_in">
<span contenteditable="true" class="spl_text_input"><?php echo $this->fadeIn; ?></span> <span contenteditable="true" class="spl_text_input"><?php echo $this->fadeIn; ?></span>
</dd> </dd>
<dd class="edit-error"></dd> <dd class="edit-error"></dd>

View File

@ -43,7 +43,8 @@ if (count($items)) : ?>
?> ?>
<div id="crossfade_<?php echo $i ?>-<?php echo $i+1 ?>" class="crossfade clearfix" style="display: none"> <div id="crossfade_<?php echo $i ?>-<?php echo $i+1 ?>" class="crossfade clearfix" style="display: none">
<?php echo $this->partial('playlist/set-fade.phtml', array( <?php echo $this->partial('playlist/set-fade.phtml', array(
'pos' => $i, 'item1' => $items[$i]['id'],
'item2' => $items[$i+1]['id'],
'fadeOut' => $items[$i]['fadeout'], 'fadeOut' => $items[$i]['fadeout'],
'fadeIn' => $items[$i+1]['fadein'])); ?> 'fadeIn' => $items[$i+1]['fadein'])); ?>
</div> </div>

View File

@ -215,7 +215,6 @@ function fnCreatedRow( nRow, aData, iDataIndex ) {
//call the context menu so we can prevent the event from propagating. //call the context menu so we can prevent the event from propagating.
$(nRow).find('td:not(.library_checkbox):not(.library_type)').click(function(e){ $(nRow).find('td:not(.library_checkbox):not(.library_type)').click(function(e){
var x;
$(this).contextMenu(); $(this).contextMenu();
@ -390,7 +389,7 @@ $(document).ready(function() {
setInterval( checkSCUploadStatus, 5000 ); setInterval( checkSCUploadStatus, 5000 );
addQtipToSCIcons(); addQtipToSCIcons();
$.contextMenu({ $.contextMenu({
selector: '#library_display td:not(.library_checkbox):not(.library_type)', selector: '#library_display td:not(.library_checkbox):not(.library_type)',
trigger: "left", trigger: "left",

View File

@ -114,10 +114,10 @@ var AIRTIME = (function(AIRTIME){
function changeFadeIn(event) { function changeFadeIn(event) {
event.stopPropagation(); event.stopPropagation();
var pos, url, fadeIn, li, unqid; var id, url, fadeIn, li, unqid;
span = $(this); span = $(this);
pos = span.parent().attr("id").split("_").pop(); id = span.parent().attr("id").split("_").pop();
url = "/Playlist/set-fade"; url = "/Playlist/set-fade";
fadeIn = $.trim(span.text()); fadeIn = $.trim(span.text());
li = span.parent().parent().parent().parent(); li = span.parent().parent().parent().parent();
@ -128,7 +128,7 @@ var AIRTIME = (function(AIRTIME){
return; return;
} }
$.post(url, {format: "json", fadeIn: fadeIn, pos: pos}, function(json){ $.post(url, {format: "json", fadeIn: fadeIn, id: id}, function(json){
if(json.response !== undefined && json.response.error) { if(json.response !== undefined && json.response.error) {
showError(span, json.response.error); showError(span, json.response.error);
@ -146,10 +146,10 @@ var AIRTIME = (function(AIRTIME){
function changeFadeOut(event) { function changeFadeOut(event) {
event.stopPropagation(); event.stopPropagation();
var pos, url, fadeOut, li, unqid; var id, url, fadeOut, li, unqid;
span = $(this); span = $(this);
pos = span.parent().attr("id").split("_").pop(); id = span.parent().attr("id").split("_").pop();
url = "/Playlist/set-fade"; url = "/Playlist/set-fade";
fadeOut = $.trim(span.text()); fadeOut = $.trim(span.text());
li = span.parent().parent().parent().parent(); li = span.parent().parent().parent().parent();
@ -160,7 +160,7 @@ var AIRTIME = (function(AIRTIME){
return; return;
} }
$.post(url, {format: "json", fadeOut: fadeOut, pos: pos}, function(json){ $.post(url, {format: "json", fadeOut: fadeOut, id: id}, function(json){
if(json.response !== undefined && json.response.error) { if(json.response !== undefined && json.response.error) {
showError(span, json.response.error); showError(span, json.response.error);
return; return;
@ -341,7 +341,7 @@ var AIRTIME = (function(AIRTIME){
else { else {
$(this).addClass("ui-state-active"); $(this).addClass("ui-state-active");
var url = '/Playlist/set-playlist-fades'; var url = '/Playlist/get-playlist-fades';
$.get(url, {format: "json"}, function(json){ $.get(url, {format: "json"}, function(json){
if(json.playlist_error == true){ if(json.playlist_error == true){
@ -425,21 +425,15 @@ var AIRTIME = (function(AIRTIME){
} }
$.post(url, {format: "json", fadeIn: fadeIn}, function(json){ $.post(url, {format: "json", fadeIn: fadeIn}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload(); hideError(span);
}
if(json.response.error) {
return;
}
hideError(span);
}); });
}); });
playlist.find("#spl_fade_out_main span:first").on("blur", function(event){ playlist.find("#spl_fade_out_main span:last").on("blur", function(event){
event.stopPropagation(); event.stopPropagation();
var url, fadeIn, span; var url, fadeOut, span;
span = $(this); span = $(this);
url = "/Playlist/set-playlist-fades"; url = "/Playlist/set-playlist-fades";
@ -451,14 +445,8 @@ var AIRTIME = (function(AIRTIME){
} }
$.post(url, {format: "json", fadeOut: fadeOut}, function(json){ $.post(url, {format: "json", fadeOut: fadeOut}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload(); hideError(span);
}
if(json.response.error) {
return;
}
hideError(span);
}); });
}); });