From bdad3b34e0e7e0bf2b1209657e85ca73015a24ba Mon Sep 17 00:00:00 2001 From: Naomi Date: Tue, 8 Feb 2011 16:10:48 -0500 Subject: [PATCH] CC-1862 playlist builder playlist fadein/out --- .zfproject.xml | 4 + .../controllers/PlaylistController.php | 90 ++++++++++++------- application/models/Playlist.php | 12 +++ .../views/scripts/playlist/index.phtml | 15 ++++ public/js/airtime/library/spl.js | 84 +++++++++++++++-- 5 files changed, 165 insertions(+), 40 deletions(-) diff --git a/.zfproject.xml b/.zfproject.xml index c93acc463..66290e350 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -28,6 +28,7 @@ + @@ -287,6 +288,9 @@ + + + diff --git a/application/controllers/PlaylistController.php b/application/controllers/PlaylistController.php index 19f36a9e2..11de58a57 100644 --- a/application/controllers/PlaylistController.php +++ b/application/controllers/PlaylistController.php @@ -19,15 +19,16 @@ class PlaylistController extends Zend_Controller_Action ->addActionContext('edit', 'json') ->addActionContext('delete-active', 'json') ->addActionContext('delete', 'json') + ->addActionContext('set-playlist-fades', 'json') ->initContext(); $this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME); } - private function getPlaylist() - { - $pl_sess = $this->pl_sess; - + private function getPlaylist() + { + $pl_sess = $this->pl_sess; + if(isset($pl_sess->id)) { $pl = Playlist::Recall($pl_sess->id); @@ -36,13 +37,13 @@ class PlaylistController extends Zend_Controller_Action return; } return $pl; - } - } - - private function changePlaylist($pl_id){ - - $pl_sess = $this->pl_sess; + } + } + private function changePlaylist($pl_id) + { + $pl_sess = $this->pl_sess; + if(isset($pl_sess->id)) { $pl = Playlist::Recall($pl_sess->id); @@ -58,10 +59,10 @@ class PlaylistController extends Zend_Controller_Action return FALSE; } $pl->lock($userInfo->id); - $pl_sess->id = $pl_id; - } + $pl_sess->id = $pl_id; + } - private function closePlaylist($pl) + private function closePlaylist($pl) { $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $res = $pl->unlock($userInfo->id); @@ -78,9 +79,6 @@ class PlaylistController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet('/css/playlist_builder.css'); $this->_helper->viewRenderer->setResponseSegment('spl'); - - $pl_sess = $this->pl_sess; - $this->view->pl = $this->getPlaylist(); } @@ -94,14 +92,12 @@ class PlaylistController extends Zend_Controller_Action $pl->setPLMetaData('dc:creator', $userInfo->login); $this->changePlaylist($pl_id); - $form = new Application_Form_PlaylistMetadata(); - $this->view->form = $form->__toString(); } public function metadataAction() - { + { $request = $this->getRequest(); $form = new Application_Form_PlaylistMetadata(); @@ -141,8 +137,8 @@ class PlaylistController extends Zend_Controller_Action public function editAction() { - $pl_id = $this->_getParam('id', null); - + $pl_id = $this->_getParam('id', null); + if(!is_null($pl_id)) { $this->changePlaylist($pl_id); } @@ -155,8 +151,8 @@ class PlaylistController extends Zend_Controller_Action } public function addItemAction() - { - $id = $this->_getParam('id'); + { + $id = $this->_getParam('id'); $pos = $this->_getParam('pos', null); if (!is_null($id)) { @@ -181,7 +177,7 @@ class PlaylistController extends Zend_Controller_Action public function moveItemAction() { - $oldPos = $this->_getParam('oldPos'); + $oldPos = $this->_getParam('oldPos'); $newPos = $this->_getParam('newPos'); $pl = $this->getPlaylist(); @@ -198,8 +194,8 @@ class PlaylistController extends Zend_Controller_Action public function deleteItemAction() { - $positions = $this->_getParam('pos', array()); - + $positions = $this->_getParam('pos', array()); + if (!is_array($positions)) $positions = array($positions); @@ -218,12 +214,12 @@ class PlaylistController extends Zend_Controller_Action $this->view->name = $pl->getName(); $this->view->length = $pl->getLength(); - unset($this->view->pl); + unset($this->view->pl); } public function setCueAction() { - $request = $this->getRequest(); + $request = $this->getRequest(); $pos = $this->_getParam('pos'); $pl = $this->getPlaylist(); @@ -248,7 +244,7 @@ class PlaylistController extends Zend_Controller_Action public function setFadeAction() { - $request = $this->getRequest(); + $request = $this->getRequest(); $pos = $this->_getParam('pos'); $pl = $this->getPlaylist(); @@ -292,8 +288,8 @@ class PlaylistController extends Zend_Controller_Action } public function deleteActiveAction() - { - $pl = $this->getPlaylist(); + { + $pl = $this->getPlaylist(); Playlist::Delete($pl->getId()); $pl_sess = $this->pl_sess; @@ -304,12 +300,38 @@ class PlaylistController extends Zend_Controller_Action public function closeAction() { - $pl = $this->getPlaylist(); + $pl = $this->getPlaylist(); $this->closePlaylist($pl); - $this->view->html = $this->view->render('playlist/index.phtml'); + $this->view->html = $this->view->render('playlist/index.phtml'); } + public function setPlaylistFadesAction() + { + $request = $this->getRequest(); + $pl = $this->getPlaylist(); + + 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]; + } + + } @@ -331,6 +353,8 @@ class PlaylistController extends Zend_Controller_Action + + diff --git a/application/models/Playlist.php b/application/models/Playlist.php index a92e28fbd..6db198122 100644 --- a/application/models/Playlist.php +++ b/application/models/Playlist.php @@ -355,6 +355,18 @@ class Playlist { return $res + 1; } + public function getSize() { + + $res = CcPlaylistQuery::create() + ->findPK($this->id) + ->computeLastPosition(); + + if(is_null($res)) + return 0; + + return $res; + } + /** * Get the entire playlist as a two dimentional array, sorted in order of play. * @return array diff --git a/application/views/scripts/playlist/index.phtml b/application/views/scripts/playlist/index.phtml index 140271b26..194636a8c 100644 --- a/application/views/scripts/playlist/index.phtml +++ b/application/views/scripts/playlist/index.phtml @@ -1,6 +1,9 @@ pl)) : ?> + + Playlist crossfade + @@ -8,6 +11,18 @@

pl->getName(); ?>

pl->getLength(); ?>

+ +
    diff --git a/public/js/airtime/library/spl.js b/public/js/airtime/library/spl.js index 7dac496dc..e6db5a7ff 100644 --- a/public/js/airtime/library/spl.js +++ b/public/js/airtime/library/spl.js @@ -392,13 +392,83 @@ function setUpSPL() { .button() .click(closeSPL); - $("#spl_main_crossfade") - .button({ - icons: { - primary: "crossfade-main-icon" - }, - text: false - }); + $("#spl_crossfade").click(function(){ + + if($(this).hasClass("ui-state-active")) { + $(this).removeClass("ui-state-active"); + $("#crossfade_main").hide(); + } + else { + $(this).addClass("ui-state-active"); + + var url = '/Playlist/set-playlist-fades'; + + $.get(url, {format: "json"}, function(json){ + $("#spl_fade_in_main").find("span") + .empty() + .append(json.fadeIn); + $("#spl_fade_out_main").find("span") + .empty() + .append(json.fadeOut); + + $("#crossfade_main").show(); + }); + } + }); + + $("#spl_fade_in_main span:first").blur(function(event){ + event.stopPropagation(); + + var url, fadeIn, span; + + span = $(this); + url = "/Playlist/set-playlist-fades"; + fadeIn = span.text().trim(); + + if(!isTimeValid(fadeIn)){ + showError(span, "please put in a time '00:00:00 (.000000)'"); + return; + } + + $.post(url, {format: "json", fadeIn: fadeIn}, function(json){ + if(json.response.error) { + return; + } + + hideError(span); + }); + }); + + $("#spl_fade_out_main span:first").blur(function(event){ + event.stopPropagation(); + + var url, fadeIn, span; + + span = $(this); + url = "/Playlist/set-playlist-fades"; + fadeOut = span.text().trim(); + + if(!isTimeValid(fadeOut)){ + showError(span, "please put in a time '00:00:00 (.000000)'"); + return; + } + + $.post(url, {format: "json", fadeOut: fadeOut}, function(json){ + if(json.response.error) { + return; + } + + hideError(span); + }); + }); + + $("#spl_fade_in_main span:first, #spl_fade_out_main span:first") + .keydown(submitOnEnter); + + $("#crossfade_main > .ui-icon-closethick").click(function(){ + $("#spl_crossfade").removeClass("ui-state-active"); + $("#crossfade_main").hide(); + }); $("#spl_delete") .button()