CC-1665: Scheduled stream rebroadcasting and recording

-use mime type so that webstreams can play with invalid filenames
This commit is contained in:
Martin Konecny 2012-08-10 12:40:28 -04:00
parent fe3f4ea678
commit 35e3b3bc02
6 changed files with 57 additions and 59 deletions

View file

@ -51,14 +51,18 @@ class AudiopreviewController extends Zend_Controller_Action
if ($type == "audioclip") {
$uri = "/api/get-media/file/".$audioFileID;
$media = Application_Model_StoredFile::Recall($audioFileID);
$mime = $media->getPropelOrm()->getDbMime();
} else if ($type == "stream") {
$webstream = CcWebstreamQuery::create()->findPk($audioFileID);
$uri = $webstream->getDbUrl();
$mime = $webstream->getDbMime();
} else {
throw new Exception("Unknown type for audio preview!");
}
$this->view->uri = $uri;
$this->view->mime = $mime;
$this->view->audioFileID = $audioFileID;
$this->view->audioFileArtist = $audioFileArtist;
$this->view->audioFileTitle = $audioFileTitle;

View file

@ -76,7 +76,7 @@ class LibraryController extends Zend_Controller_Action
$obj = new Application_Model_Playlist($id);
} else {
$obj = new Application_Model_Block($id);
if (!$obj->isStatic()){
if (!$obj->isStatic()) {
unset($menu["play"]);
}
if (($isAdminOrPM || $obj->getCreatorId() == $user->getId()) && $screen == "playlist") {
@ -96,7 +96,8 @@ class LibraryController extends Zend_Controller_Action
}
} else if ($type == "stream") {
$obj = new Application_Model_Webstream($id);
$webstream = CcWebstreamQuery::create()->findPK($id);
$obj = new Application_Model_Webstream($webstream);
if (isset($this->obj_sess->id) && $screen == "playlist") {
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
if ($this->obj_sess->type === "playlist") {
@ -330,7 +331,9 @@ class LibraryController extends Zend_Controller_Action
}
$this->view->block = $block;
} else if ($type == "stream") {
$file = new Application_Model_Webstream($id);
$webstream = CcWebstreamQuery::create()->findPK($id);
$file = new Application_Model_Webstream($webstream);
$md = $file->getMetadata();

View file

@ -15,19 +15,19 @@ class WebstreamController extends Zend_Controller_Action
public function newAction()
{
$this->view->ws = new Application_Model_Webstream();
$webstream = new CcWebstream();
//we're not saving this primary key in the DB so it's OK
$webstream->setDbId(-1);
$webstream->setDbName("Untitled Webstream");
$webstream->setDbDescription("");
$webstream->setDbUrl("http://");
$webstream->setDbLength("00:00:00");
$webstream->setDbName("Untitled Webstream");
$this->view->ws = new Application_Model_Webstream($webstream);
$this->view->html = $this->view->render('webstream/webstream.phtml');
/*
$pl_sess = $this->pl_sess;
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$pl = new Application_Model_Playlist();
$pl->setName("Untitled Playlist");
$pl->setPLMetaData('dc:creator', $userInfo->id);
$this->changePlaylist($pl->getId());
$this->createFullResponse($pl);
*/
}
public function editAction()
@ -39,7 +39,8 @@ class WebstreamController extends Zend_Controller_Action
throw new Exception("Missing parameter 'id'");
}
$this->view->ws = new Application_Model_Webstream($id);
$webstream = CcWebstreamQuery::create()->findPK($id);
$this->view->ws = new Application_Model_Webstream($webstream);
$this->view->html = $this->view->render('webstream/webstream.phtml');
}
@ -52,8 +53,15 @@ class WebstreamController extends Zend_Controller_Action
$hasPermission = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST));
$id = $request->getParam("id");
if ($id != -1) {
$webstream = CcWebstreamQuery::create()->findPK($id);
$parameters = array();
$parameters['id'] = trim($request->getParam("id"));
$parameters['length'] = trim($request->getParam("length"));
$parameters['name'] = trim($request->getParam("name"));
$parameters['description'] = trim($request->getParam("description"));
$parameters['url'] = trim($request->getParam("url"));
if ($parameters['id'] != -1) {
$webstream = CcWebstreamQuery::create()->findPK($parameters['id']);
//we are updating a playlist. Ensure that if the user is a host/dj, that he has the correct permission.
$user = Application_Model_User::getCurrentUser();
if ($webstream->getDbCreatorId() != $user->getId()) {
@ -67,15 +75,16 @@ class WebstreamController extends Zend_Controller_Action
return;
}
$analysis = Application_Model_Webstream::analyzeFormData($request);
$analysis = Application_Model_Webstream::analyzeFormData($parameters);
try {
if (Application_Model_Webstream::isValid($analysis)) {
Application_Model_Webstream::save($request, $id);
Application_Model_Webstream::save($parameters);
$this->view->statusMessage = "<div class='success'>Webstream saved.</div>";
} else {
throw new Exception();
}
} catch (Exception $e) {
Logging::log($e);
$this->view->statusMessage = "<div class='errors'>Invalid form values.</div>";
$this->view->analysis = $analysis;
}