diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index 229ddad0f..b5edfbfb4 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -74,7 +74,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap //scripts for now playing bar $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/common/common.js','text/javascript'); diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 68ae26f61..8c08ae866 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -16,6 +16,7 @@ class PlaylistController extends Zend_Controller_Action ->addActionContext('edit', 'json') ->addActionContext('delete', 'json') ->addActionContext('set-playlist-fades', 'json') + ->addActionContext('get-playlist-fades', 'json') ->addActionContext('set-playlist-name', 'json') ->addActionContext('set-playlist-description', 'json') ->initContext(); @@ -265,52 +266,73 @@ class PlaylistController extends Zend_Controller_Action public function setFadeAction() { - $pos = $this->_getParam('pos'); - $pl = $this->getPlaylist(); - if($pl === false){ - $this->view->playlist_error = true; - return false; - } - + $id = $this->_getParam('id'); $fadeIn = $this->_getParam('fadeIn', 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"])) { - $this->createUpdateResponse($pl); + if (!isset($response["error"])) { + $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() { - $request = $this->getRequest(); - $pl = $this->getPlaylist(); - if($pl === false){ - $this->view->playlist_error = true; - return false; + $fadeIn = $this->_getParam('fadeIn', null); + $fadeOut = $this->_getParam('fadeOut', null); + + try { + $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() diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index 89d7a32f4..a2653e9e5 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -389,6 +389,8 @@ class Application_Model_Playlist { public function getFadeInfo($pos) { + Logging::log("Getting fade info for pos {$pos}"); + $row = CcPlaylistcontentsQuery::create() ->joinWith(CcFilesPeer::OM_CLASS) ->filterByDbPlaylistId($this->id) @@ -412,21 +414,18 @@ class Application_Model_Playlist { * new value in ss.ssssss or extent format * @return boolean */ - public function changeFadeInfo($pos, $fadeIn, $fadeOut) + public function changeFadeInfo($id, $fadeIn, $fadeOut) { $errArray= array(); $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME); - if(is_null($pos) || $pos < 0 || $pos >= $this->getNextPos()) { - $errArray["error"]="Invalid position."; + $row = CcPlaylistcontentsQuery::create()->findPK($id); + + if (is_null($row)) { + $errArray["error"]="Playlist item does not exist."; return $errArray; } - $row = CcPlaylistcontentsQuery::create() - ->filterByDbPlaylistId($this->id) - ->filterByDbPosition($pos) - ->findOne(); - $clipLength = $row->getDbCliplength(); if(!is_null($fadeIn)) { @@ -457,6 +456,28 @@ class Application_Model_Playlist { 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 * diff --git a/airtime_mvc/application/views/scripts/playlist/set-fade.phtml b/airtime_mvc/application/views/scripts/playlist/set-fade.phtml index 1c9135323..4a55fb2db 100644 --- a/airtime_mvc/application/views/scripts/playlist/set-fade.phtml +++ b/airtime_mvc/application/views/scripts/playlist/set-fade.phtml @@ -1,11 +1,11 @@