CC-1665: Scheduled stream rebroadcasting and recording

-ability to preview webstreams inside of playlists
This commit is contained in:
Martin Konecny 2012-08-09 16:49:20 -04:00
parent 952f18dc3c
commit c73328e297
2 changed files with 85 additions and 63 deletions

View File

@ -101,49 +101,49 @@ class AudiopreviewController extends Zend_Controller_Action
public function blockPreviewAction() public function blockPreviewAction()
{ {
global $CC_CONFIG; global $CC_CONFIG;
$blockIndex = $this->_getParam('blockIndex'); $blockIndex = $this->_getParam('blockIndex');
$blockId = $this->_getParam('blockId'); $blockId = $this->_getParam('blockId');
$request = $this->getRequest(); $request = $this->getRequest();
$baseUrl = $request->getBaseUrl(); $baseUrl = $request->getBaseUrl();
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']); $baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/audiopreview/preview_jplayer.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/audiopreview/preview_jplayer.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/jplayer/jplayer.playlist.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/jplayer/jplayer.playlist.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/js/jplayer/skin/jplayer.airtime.audio.preview.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'/js/jplayer/skin/jplayer.airtime.audio.preview.css?'.$CC_CONFIG['airtime_version']);
$this->_helper->layout->setLayout('audioPlayer'); $this->_helper->layout->setLayout('audioPlayer');
$logo = Application_Model_Preference::GetStationLogo(); $logo = Application_Model_Preference::GetStationLogo();
if ($logo) { if ($logo) {
$this->view->logo = "data:image/png;base64,$logo"; $this->view->logo = "data:image/png;base64,$logo";
} else { } else {
$this->view->logo = "$baseUrl/css/images/airtime_logo_jp.png"; $this->view->logo = "$baseUrl/css/images/airtime_logo_jp.png";
} }
$this->view->blockIndex= $blockIndex; $this->view->blockIndex= $blockIndex;
$this->view->blockId = $blockId; $this->view->blockId = $blockId;
$this->_helper->viewRenderer->setRender('audio-preview'); $this->_helper->viewRenderer->setRender('audio-preview');
} }
public function getBlockAction() public function getBlockAction()
{ {
// disable the view and the layout // disable the view and the layout
$this->view->layout()->disableLayout(); $this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true); $this->_helper->viewRenderer->setNoRender(true);
$blockId = $this->_getParam('blockId'); $blockId = $this->_getParam('blockId');
if (!isset($blockId)) { if (!isset($blockId)) {
return; return;
} }
$bl = new Application_Model_Block($blockId); $bl = new Application_Model_Block($blockId);
$result = array(); $result = array();
foreach ($bl->getContents(true) as $ele) { foreach ($bl->getContents(true) as $ele) {
$result[] = $this->createElementMap($ele); $result[] = $this->createElementMap($ele);
} }
$this->_helper->json($result); $this->_helper->json($result);
} }
/** /**
@ -173,26 +173,40 @@ class AudiopreviewController extends Zend_Controller_Action
$result[] = $this->createElementMap($track); $result[] = $this->createElementMap($track);
} }
} }
}else{ } else {
$result[] = $this->createElementMap($ele); $result[] = $this->createElementMap($ele);
} }
} }
$this->_helper->json($result); $this->_helper->json($result);
} }
function createElementMap($track){ private function createElementMap($track)
$elementMap = array( 'element_title' => isset($track['track_title'])?$track['track_title']:"", {
'element_artist' => isset($track['artist_name'])?$track['artist_name']:"", $elementMap = array( 'element_title' => isset($track['track_title'])?$track['track_title']:"",
'element_id' => isset($track['id'])?$track['id']:"", 'element_artist' => isset($track['artist_name'])?$track['artist_name']:"",
'element_position' => isset($track['position'])?$track['position']:"", 'element_id' => isset($track['id'])?$track['id']:"",
); 'element_position' => isset($track['position'])?$track['position']:"",
$fileExtension = pathinfo($track['path'], PATHINFO_EXTENSION); );
if (strtolower($fileExtension) === 'mp3') {
$elementMap['element_mp3'] = $track['item_id'];
} else if (strtolower($fileExtension) === 'ogg') { $elementMap['type'] = $track['type'];
$elementMap['element_oga'] = $track['item_id'];
} else { if ($track['type'] == 0) {
//the media was neither mp3 or ogg $fileExtension = pathinfo($track['path'], PATHINFO_EXTENSION);
//type is file
//TODO: use MIME type for this
if (strtolower($fileExtension) === 'mp3') {
$elementMap['element_mp3'] = $track['item_id'];
} else if (strtolower($fileExtension) === 'ogg') {
$elementMap['element_oga'] = $track['item_id'];
} else {
//the media was neither mp3 or ogg
throw new Exception("Unknown file type");
}
$elementMap['uri'] = "/api/get-media/file/".$track['item_id'];
} else {
$elementMap['uri'] = $track['path'];
} }
return $elementMap; return $elementMap;
} }

View File

@ -76,7 +76,7 @@ function playAllPlaylist(p_playlistID, p_playlistIndex) {
if ( _idToPostionLookUp !== undefined && viewsPlaylistID == p_playlistID ) { if ( _idToPostionLookUp !== undefined && viewsPlaylistID == p_playlistID ) {
play(p_playlistIndex); play(p_playlistIndex);
}else { } else {
buildplaylist("/audiopreview/get-playlist/playlistID/"+p_playlistID, p_playlistIndex); buildplaylist("/audiopreview/get-playlist/playlistID/"+p_playlistID, p_playlistIndex);
} }
} }
@ -87,7 +87,7 @@ function playBlock(p_blockId, p_blockIndex)
if ( _idToPostionLookUp !== undefined && viewsBlockId == p_blockId ) { if ( _idToPostionLookUp !== undefined && viewsBlockId == p_blockId ) {
play(p_blockIndex); play(p_blockIndex);
}else { } else {
buildplaylist("/audiopreview/get-block/blockId/"+p_blockId, p_blockIndex); buildplaylist("/audiopreview/get-block/blockId/"+p_blockId, p_blockIndex);
} }
} }
@ -124,20 +124,28 @@ function buildplaylist(p_url, p_playIndex) {
var index; var index;
var total = 0; var total = 0;
for(index in data){ for(index in data){
if (data[index]['element_mp3'] != undefined){ if (data[index]['type'] == 0) {
media = {title: data[index]['element_title'], if (data[index]['element_mp3'] != undefined){
media = {title: data[index]['element_title'],
artist: data[index]['element_artist'],
mp3:data[index]['uri']
};
} else if (data[index]['element_oga'] != undefined) {
media = {title: data[index]['element_title'],
artist: data[index]['element_artist'],
oga:data[index]['uri']
};
}
} else if (data[index]['type'] == 1) {
media = {title: data[index]['element_title'],
artist: data[index]['element_artist'], artist: data[index]['element_artist'],
mp3:"/api/get-media/file/"+data[index]['element_mp3'] mp3:data[index]['uri']
};
}else if (data[index]['element_oga'] != undefined) {
media = {title: data[index]['element_title'],
artist: data[index]['element_artist'],
oga:"/api/get-media/file/"+data[index]['element_oga']
}; };
} }
myPlaylist[index] = media; if (media) {
myPlaylist[index] = media;
}
// we should create a map according to the new position in the player itself // we should create a map according to the new position in the player itself
// total is the index on the player // total is the index on the player
_idToPostionLookUp[data[index]['element_id']] = total; _idToPostionLookUp[data[index]['element_id']] = total;