2012-03-15 22:56:51 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class AudiopreviewController extends Zend_Controller_Action
|
|
|
|
{
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
|
|
|
$ajaxContext->addActionContext('show-preview', 'json')
|
2021-10-11 16:10:47 +02:00
|
|
|
->addActionContext('audio-preview', 'json')
|
|
|
|
->addActionContext('get-show', 'json')
|
|
|
|
->addActionContext('playlist-preview', 'json')
|
|
|
|
->addActionContext('get-playlist', 'json')
|
2022-01-23 19:15:55 +01:00
|
|
|
->initContext();
|
2012-03-15 22:56:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Simply sets up the view to play the required audio track.
|
|
|
|
* Gets the parameters from the request and sets them to the view.
|
|
|
|
*/
|
|
|
|
public function audioPreviewAction()
|
|
|
|
{
|
2013-01-14 22:16:14 +01:00
|
|
|
$CC_CONFIG = Config::getConfig();
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$audioFileID = $this->_getParam('audioFileID');
|
2012-08-09 20:39:31 +02:00
|
|
|
$type = $this->_getParam('type');
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2022-07-07 23:27:28 +02:00
|
|
|
$baseUrl = Config::getBasePath();
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-08-09 20:39:31 +02:00
|
|
|
$this->view->headScript()->appendFile(
|
2022-09-19 11:58:31 +02:00
|
|
|
Assets::url('js/airtime/audiopreview/preview_jplayer.js'),
|
2021-10-11 16:10:47 +02:00
|
|
|
'text/javascript'
|
|
|
|
);
|
2012-08-09 20:39:31 +02:00
|
|
|
$this->view->headScript()->appendFile(
|
2022-09-19 11:58:31 +02:00
|
|
|
Assets::url('js/jplayer/jplayer.playlist.min.js'),
|
2021-10-11 16:10:47 +02:00
|
|
|
'text/javascript'
|
|
|
|
);
|
2012-08-09 20:39:31 +02:00
|
|
|
$this->view->headLink()->appendStylesheet(
|
2022-09-19 11:58:31 +02:00
|
|
|
Assets::url('js/jplayer/skin/jplayer.airtime.audio.preview.css')
|
2021-10-11 16:10:47 +02:00
|
|
|
);
|
2012-03-15 22:56:51 +01:00
|
|
|
$this->_helper->layout->setLayout('audioPlayer');
|
|
|
|
|
|
|
|
$logo = Application_Model_Preference::GetStationLogo();
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($logo) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->logo = "data:image/png;base64,{$logo}";
|
2012-03-15 22:56:51 +01:00
|
|
|
} else {
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->logo = $baseUrl . 'css/images/airtime_logo_jp.png';
|
2012-03-15 22:56:51 +01:00
|
|
|
}
|
2012-08-09 20:39:31 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($type == 'audioclip') {
|
2013-04-20 02:24:05 +02:00
|
|
|
$media = Application_Model_StoredFile::RecallById($audioFileID);
|
2021-10-11 16:10:47 +02:00
|
|
|
$uri = $baseUrl . 'api/get-media/file/' . $audioFileID;
|
|
|
|
$mime = $media->getPropelOrm()->getDbMime();
|
2015-02-26 17:09:43 +01:00
|
|
|
$this->view->audioFileArtist = htmlspecialchars($media->getPropelOrm()->getDbArtistName());
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->audioFileTitle = htmlspecialchars($media->getPropelOrm()->getDbTrackTitle());
|
|
|
|
} elseif ($type == 'stream') {
|
2012-08-09 20:39:31 +02:00
|
|
|
$webstream = CcWebstreamQuery::create()->findPk($audioFileID);
|
2021-10-11 16:10:47 +02:00
|
|
|
$uri = $webstream->getDbUrl();
|
|
|
|
$mime = $webstream->getDbMime();
|
|
|
|
$this->view->audioFileTitle = htmlspecialchars($webstream->getDbName());
|
2012-08-09 20:39:31 +02:00
|
|
|
} else {
|
2021-10-11 16:10:47 +02:00
|
|
|
throw new Exception("Unknown type for audio preview!.Type={$type}");
|
2012-08-09 20:39:31 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->uri = $uri;
|
|
|
|
$this->view->mime = $mime;
|
|
|
|
$this->view->audioFileID = $audioFileID;
|
2015-02-20 20:27:16 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->type = $type;
|
2012-03-15 22:56:51 +01:00
|
|
|
|
|
|
|
$this->_helper->viewRenderer->setRender('audio-preview');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Simply sets up the view to play the required playlist track.
|
|
|
|
* Gets the parameters from the request and sets them to the view.
|
|
|
|
*/
|
|
|
|
public function playlistPreviewAction()
|
|
|
|
{
|
2013-01-14 22:16:14 +01:00
|
|
|
$CC_CONFIG = Config::getConfig();
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-03-15 22:56:51 +01:00
|
|
|
$playlistIndex = $this->_getParam('playlistIndex');
|
|
|
|
$playlistID = $this->_getParam('playlistID');
|
|
|
|
|
2022-07-07 23:27:28 +02:00
|
|
|
$baseUrl = Config::getBasePath();
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2022-09-19 11:58:31 +02:00
|
|
|
$this->view->headScript()->appendFile(Assets::url('js/airtime/audiopreview/preview_jplayer.js'), 'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile(Assets::url('js/jplayer/jplayer.playlist.min.js'), 'text/javascript');
|
|
|
|
$this->view->headLink()->appendStylesheet(Assets::url('js/jplayer/skin/jplayer.airtime.audio.preview.css'));
|
2012-03-15 22:56:51 +01:00
|
|
|
$this->_helper->layout->setLayout('audioPlayer');
|
|
|
|
|
|
|
|
$logo = Application_Model_Preference::GetStationLogo();
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($logo) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->logo = "data:image/png;base64,{$logo}";
|
2012-03-15 22:56:51 +01:00
|
|
|
} else {
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->logo = $baseUrl . 'css/images/airtime_logo_jp.png';
|
2012-03-15 22:56:51 +01:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->playlistIndex = $playlistIndex;
|
2012-03-15 22:56:51 +01:00
|
|
|
$this->view->playlistID = $playlistID;
|
|
|
|
|
|
|
|
$this->_helper->viewRenderer->setRender('audio-preview');
|
|
|
|
}
|
|
|
|
|
2012-08-02 22:36:12 +02:00
|
|
|
public function blockPreviewAction()
|
|
|
|
{
|
2013-01-14 22:16:14 +01:00
|
|
|
$CC_CONFIG = Config::getConfig();
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-09 22:49:20 +02:00
|
|
|
$blockIndex = $this->_getParam('blockIndex');
|
|
|
|
$blockId = $this->_getParam('blockId');
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2022-07-07 23:27:28 +02:00
|
|
|
$baseUrl = Config::getBasePath();
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2022-09-19 11:58:31 +02:00
|
|
|
$this->view->headScript()->appendFile(Assets::url('js/airtime/audiopreview/preview_jplayer.js'), 'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile(Assets::url('js/jplayer/jplayer.playlist.min.js'), 'text/javascript');
|
|
|
|
$this->view->headLink()->appendStylesheet(Assets::url('js/jplayer/skin/jplayer.airtime.audio.preview.css'));
|
2012-08-09 22:49:20 +02:00
|
|
|
$this->_helper->layout->setLayout('audioPlayer');
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-09 22:49:20 +02:00
|
|
|
$logo = Application_Model_Preference::GetStationLogo();
|
|
|
|
if ($logo) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->logo = "data:image/png;base64,{$logo}";
|
2012-08-09 22:49:20 +02:00
|
|
|
} else {
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->logo = $baseUrl . 'css/images/airtime_logo_jp.png';
|
2012-08-09 22:49:20 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->blockIndex = $blockIndex;
|
2012-08-09 22:49:20 +02:00
|
|
|
$this->view->blockId = $blockId;
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-02 22:36:12 +02:00
|
|
|
$this->_helper->viewRenderer->setRender('audio-preview');
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2012-08-02 22:36:12 +02:00
|
|
|
public function getBlockAction()
|
|
|
|
{
|
2012-08-09 22:49:20 +02:00
|
|
|
// disable the view and the layout
|
|
|
|
$this->view->layout()->disableLayout();
|
|
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-09 22:49:20 +02:00
|
|
|
$blockId = $this->_getParam('blockId');
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-09 22:49:20 +02:00
|
|
|
if (!isset($blockId)) {
|
|
|
|
return;
|
|
|
|
}
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-02 22:36:12 +02:00
|
|
|
$bl = new Application_Model_Block($blockId);
|
2021-10-11 16:10:47 +02:00
|
|
|
$result = [];
|
2012-08-02 22:36:12 +02:00
|
|
|
foreach ($bl->getContents(true) as $ele) {
|
|
|
|
$result[] = $this->createElementMap($ele);
|
2012-08-09 22:49:20 +02:00
|
|
|
}
|
2012-08-02 22:36:12 +02:00
|
|
|
$this->_helper->json($result);
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2012-03-15 22:56:51 +01:00
|
|
|
/**
|
|
|
|
*Function will load and return the contents of the requested playlist.
|
|
|
|
*/
|
2012-07-16 03:17:13 +02:00
|
|
|
public function getPlaylistAction()
|
|
|
|
{
|
2012-03-15 22:56:51 +01:00
|
|
|
// disable the view and the layout
|
|
|
|
$this->view->layout()->disableLayout();
|
|
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-03-15 22:56:51 +01:00
|
|
|
$playlistID = $this->_getParam('playlistID');
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if (!isset($playlistID)) {
|
2012-03-15 22:56:51 +01:00
|
|
|
return;
|
|
|
|
}
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-03-15 22:56:51 +01:00
|
|
|
$pl = new Application_Model_Playlist($playlistID);
|
2021-10-11 16:10:47 +02:00
|
|
|
$result = [];
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-07-27 17:51:50 +02:00
|
|
|
foreach ($pl->getContents(true) as $ele) {
|
|
|
|
if ($ele['type'] == 2) {
|
|
|
|
// if element is a block expand and add
|
|
|
|
$bl = new Application_Model_Block($ele['item_id']);
|
|
|
|
if ($bl->isStatic()) {
|
|
|
|
foreach ($bl->getContents(true) as $track) {
|
|
|
|
$result[] = $this->createElementMap($track);
|
|
|
|
}
|
|
|
|
}
|
2012-08-09 22:49:20 +02:00
|
|
|
} else {
|
2012-07-27 17:51:50 +02:00
|
|
|
$result[] = $this->createElementMap($ele);
|
2012-03-15 22:56:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->_helper->json($result);
|
|
|
|
}
|
2012-08-29 16:54:36 +02:00
|
|
|
|
|
|
|
private function createElementMap($track)
|
2012-08-09 22:49:20 +02:00
|
|
|
{
|
2022-07-07 23:27:28 +02:00
|
|
|
$baseUrl = Config::getBasePath();
|
2013-01-10 16:52:39 +01:00
|
|
|
|
2022-07-07 20:01:15 +02:00
|
|
|
$elementMap = [
|
|
|
|
'element_title' => isset($track['track_title']) ? $track['track_title'] : '',
|
2021-10-11 16:10:47 +02:00
|
|
|
'element_artist' => isset($track['artist_name']) ? $track['artist_name'] : '',
|
|
|
|
'element_id' => isset($track['id']) ? $track['id'] : '',
|
|
|
|
'element_position' => isset($track['position']) ? $track['position'] : '',
|
|
|
|
'mime' => isset($track['mime']) ? $track['mime'] : '',
|
|
|
|
];
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-15 18:10:56 +02:00
|
|
|
/* If the track type is static we know it must be
|
|
|
|
* a track because static blocks can only contain
|
|
|
|
* tracks
|
|
|
|
*/
|
|
|
|
if ($track['type'] == 'static') {
|
|
|
|
$track['type'] = 0;
|
|
|
|
}
|
2012-08-09 22:49:20 +02:00
|
|
|
$elementMap['type'] = $track['type'];
|
|
|
|
|
|
|
|
if ($track['type'] == 0) {
|
2015-07-07 21:48:22 +02:00
|
|
|
$mime = trim(strtolower($track['mime']));
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2015-07-07 21:48:22 +02:00
|
|
|
try {
|
|
|
|
$elementMap['element_' . FileDataHelper::getAudioMimeTypeArray()[$mime]] = $track['item_id'];
|
|
|
|
} catch (Exception $e) {
|
2021-10-11 16:10:47 +02:00
|
|
|
throw new Exception("Unknown file type: {$mime}");
|
2012-08-09 22:49:20 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$elementMap['uri'] = $baseUrl . 'api/get-media/file/' . $track['item_id'];
|
2012-08-09 22:49:20 +02:00
|
|
|
} else {
|
|
|
|
$elementMap['uri'] = $track['path'];
|
2012-07-27 17:51:50 +02:00
|
|
|
}
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-07-27 17:51:50 +02:00
|
|
|
return $elementMap;
|
|
|
|
}
|
2012-03-15 22:56:51 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Simply sets up the view to play the required show track.
|
|
|
|
* Gets the parameters from the request and sets them to the view.
|
|
|
|
*/
|
|
|
|
public function showPreviewAction()
|
|
|
|
{
|
2013-01-14 22:16:14 +01:00
|
|
|
$CC_CONFIG = Config::getConfig();
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-03-15 22:56:51 +01:00
|
|
|
$showID = $this->_getParam('showID');
|
|
|
|
$showIndex = $this->_getParam('showIndex');
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2022-07-07 23:27:28 +02:00
|
|
|
$baseUrl = Config::getBasePath();
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2022-09-19 11:58:31 +02:00
|
|
|
$this->view->headScript()->appendFile(Assets::url('js/airtime/audiopreview/preview_jplayer.js'), 'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile(Assets::url('js/jplayer/jplayer.playlist.min.js'), 'text/javascript');
|
|
|
|
$this->view->headLink()->appendStylesheet(Assets::url('js/jplayer/skin/jplayer.airtime.audio.preview.css'));
|
2012-03-15 22:56:51 +01:00
|
|
|
$this->_helper->layout->setLayout('audioPlayer');
|
|
|
|
|
|
|
|
$logo = Application_Model_Preference::GetStationLogo();
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($logo) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->logo = "data:image/png;base64,{$logo}";
|
2012-03-15 22:56:51 +01:00
|
|
|
} else {
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->view->logo = $baseUrl . 'css/images/airtime_logo_jp.png';
|
2012-03-15 22:56:51 +01:00
|
|
|
}
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-03-15 22:56:51 +01:00
|
|
|
$this->view->showID = $showID;
|
|
|
|
$this->view->showIndex = $showIndex;
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-03-15 22:56:51 +01:00
|
|
|
$this->_helper->viewRenderer->setRender('audio-preview');
|
|
|
|
}
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-03-15 22:56:51 +01:00
|
|
|
/**
|
|
|
|
*Function will load and return the contents of the requested show.
|
|
|
|
*/
|
|
|
|
public function getShowAction()
|
|
|
|
{
|
2022-07-07 23:27:28 +02:00
|
|
|
$baseUrl = Config::getBasePath();
|
2012-03-15 22:56:51 +01:00
|
|
|
// disable the view and the layout
|
|
|
|
$this->view->layout()->disableLayout();
|
|
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-03-15 22:56:51 +01:00
|
|
|
$showID = $this->_getParam('showID');
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if (!isset($showID)) {
|
2012-03-15 22:56:51 +01:00
|
|
|
return;
|
|
|
|
}
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-03-15 22:56:51 +01:00
|
|
|
$showInstance = new Application_Model_ShowInstance($showID);
|
2021-10-11 16:10:47 +02:00
|
|
|
$result = [];
|
2012-03-15 22:56:51 +01:00
|
|
|
$position = 0;
|
2012-07-16 03:17:13 +02:00
|
|
|
foreach ($showInstance->getShowListContent() as $track) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$elementMap = [
|
|
|
|
'element_title' => isset($track['track_title']) ? $track['track_title'] : '',
|
|
|
|
'element_artist' => isset($track['creator']) ? $track['creator'] : '',
|
2012-03-27 16:27:43 +02:00
|
|
|
'element_position' => $position,
|
|
|
|
'element_id' => ++$position,
|
2021-10-11 16:10:47 +02:00
|
|
|
'mime' => isset($track['mime']) ? $track['mime'] : '',
|
|
|
|
];
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-08-29 16:54:36 +02:00
|
|
|
$elementMap['type'] = $track['type'];
|
2012-08-09 23:42:25 +02:00
|
|
|
if ($track['type'] == 0) {
|
2015-07-07 21:48:22 +02:00
|
|
|
$mime = trim(strtolower($track['mime']));
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2015-07-07 21:48:22 +02:00
|
|
|
try {
|
|
|
|
$elementMap['element_' . FileDataHelper::getAudioMimeTypeArray()[$mime]] = $track['item_id'];
|
|
|
|
} catch (Exception $e) {
|
2021-10-11 16:10:47 +02:00
|
|
|
throw new Exception("Unknown file type: {$mime}");
|
2012-08-09 23:42:25 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$elementMap['uri'] = $baseUrl . 'api/get-media/file/' . $track['item_id'];
|
2012-03-15 22:56:51 +01:00
|
|
|
} else {
|
2012-08-10 00:14:53 +02:00
|
|
|
$elementMap['uri'] = $track['filepath'];
|
2012-03-15 22:56:51 +01:00
|
|
|
}
|
|
|
|
$result[] = $elementMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->_helper->json($result);
|
|
|
|
}
|
2012-04-19 01:02:29 +02:00
|
|
|
}
|