diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 3f0dd66b7..ab42823e7 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -417,6 +417,33 @@ class PlaylistController extends Zend_Controller_Action $this->playlistUnknownError($e); } } + + public function setCrossFadeAction() + { + $id = $this->_getParam('id'); + $fadeIn = $this->_getParam('fadeIn', 0); + $fadeOut = $this->_getParam('fadeOut', 0); + $type = $this->_getParam('type'); + $offset = $this->_getParam('offset', 0); + + try { + $obj = $this->getPlaylist($type); + $response = $obj->changeFadeInfo($id, $fadeIn, $fadeOut); + + if (!isset($response["error"])) { + $this->createUpdateResponse($obj); + $this->view->response = $response; + } else { + $this->view->fade_error = $response["error"]; + } + } catch (PlaylistOutDatedException $e) { + $this->playlistOutdated($e); + } catch (PlaylistNotFoundException $e) { + $this->playlistNotFound($type); + } catch (Exception $e) { + $this->playlistUnknownError($e); + } + } public function getPlaylistFadesAction() { diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index 764a8695c..e5610ec4f 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -645,12 +645,39 @@ SQL; return array($fadeIn, $fadeOut); } + + /* + * create a crossfade from item in cc_playlist_contents with $id1 to item $id2. + * + * $fadeOut length of fade out in seconds if $id1 + * $fadeIn length of fade in in seconds of $id2 + * $offset time in seconds from end of $id1 that $id2 will begin to play. + */ + public function createCrossfade($id1, $id2, $fadeIn, $fadeOut, $offset) + { + $this->con->beginTransaction(); + + try { + $this->changeFadeInfo($id1, null, $fadeOut); + $this->changeFadeInfo($id2, $fadeIn, null); + + $item = CcPlaylistcontentsQuery::create()->findPK($id2); + $item->setDbOffset($offset); + $item->save($this->con); + + $this->con->commit(); + + } catch (Exception $e) { + $this->con->rollback(); + throw $e; + } + } /** * Change fadeIn and fadeOut values for playlist Element * - * @param int $pos - * position of audioclip in playlist + * @param int $id + * id of audioclip in playlist contents table. * @param string $fadeIn * new value in ss.ssssss or extent format * @param string $fadeOut