/** * 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() { global $CC_CONFIG; $audioFileID = $this->_getParam('audioFileID'); $audioFileArtist = $this->_getParam('audioFileArtist'); $audioFileTitle = $this->_getParam('audioFileTitle'); $type = $this->_getParam('type'); $request = $this->getRequest(); $baseUrl = $request->getBaseUrl(); $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->headLink()->appendStylesheet($baseUrl . '/js/jplayer/skin/jplayer.airtime.audio.preview.css?' . $CC_CONFIG['airtime_version']); $this->_helper->layout->setLayout('audioPlayer'); $logo = Application_Model_Preference::GetStationLogo(); if ($logo) { $this->view->logo = "data:image/png;base64,{$logo}"; } else { $this->view->logo = "{$baseUrl}/css/images/airtime_logo_jp.png"; } if ($type == "audioclip") { $uri = "/api/get-media/file/" . $audioFileID; $media = Application_Model_StoredFile::Recall($audioFileID); $mime = $media->getPropelOrm()->getDbMime(); } elseif ($type == "stream") { $webstream = CcWebstreamQuery::create()->findPk($audioFileID); $uri = $webstream->getDbUrl(); $mime = $webstream->getDbMime(); } else { throw new Exception("Unknown type for audio preview!.Type={$type}"); } $this->view->uri = $uri; $this->view->mime = $mime; $this->view->audioFileID = $audioFileID; $this->view->audioFileArtist = $audioFileArtist; $this->view->audioFileTitle = $audioFileTitle; $this->view->type = $type; $this->_helper->viewRenderer->setRender('audio-preview'); }
public function getRecordedFile() { $file_id = $this->_showInstance->getDbRecordedFile(); if (isset($file_id)) { $file = Application_Model_StoredFile::Recall($file_id); if (isset($file) && file_exists($file->getFilePath())) { return $file; } } return null; }
public function contentContextMenuAction() { global $CC_CONFIG; $id = $this->_getParam('id'); $params = '/format/json/id/#id#/'; $paramsPop = str_replace('#id#', $id, $params); // added for downlaod $id = $this->_getParam('id'); $file_id = $this->_getParam('id', null); $file = Application_Model_StoredFile::Recall($file_id); $baseUrl = $this->getRequest()->getBaseUrl(); $url = $file->getRelativeFileUrl($baseUrl) . '/download/true'; $menu[] = array('action' => array('type' => 'gourl', 'url' => $url), 'title' => 'Download'); //returns format jjmenu is looking for. die(json_encode($menu)); }
private function makeHeaderRow($p_item) { $row = $this->defaultRowArray; $this->isAllowed($p_item, $row); $this->getRowTimestamp($p_item, $row); $this->getItemColor($p_item, $row); $showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC")); $showStartDT->setTimezone(new DateTimeZone($this->timezone)); $startsEpoch = floatval($showStartDT->format("U.u")); $showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC")); $showEndDT->setTimezone(new DateTimeZone($this->timezone)); $endsEpoch = floatval($showEndDT->format("U.u")); //is a rebroadcast show if (intval($p_item["si_rebroadcast"]) === 1) { $row["rebroadcast"] = true; $parentInstance = CcShowInstancesQuery::create()->findPk($p_item["parent_show"]); $name = $parentInstance->getCcShow()->getDbName(); $dt = $parentInstance->getDbStarts(null); $dt->setTimezone(new DateTimeZone($this->timezone)); $time = $dt->format("Y-m-d H:i"); $row["rebroadcast_title"] = "Rebroadcast of {$name} from {$time}"; } elseif (intval($p_item["si_record"]) === 1) { $row["record"] = true; // at the time of creating on show, the recorded file is not in the DB yet. // therefore, 'si_file_id' is null. So we need to check it. if (Application_Model_Preference::GetUploadToSoundcloudOption() && isset($p_item['si_file_id'])) { $file = Application_Model_StoredFile::Recall($p_item['si_file_id']); if (isset($file)) { $sid = $file->getSoundCloudId(); $row['soundcloud_id'] = $sid; } } } if ($startsEpoch < $this->epoch_now && $endsEpoch > $this->epoch_now) { $row["currentShow"] = true; $this->currentShow = true; } else { $this->currentShow = false; } $row["header"] = true; $row["starts"] = $showStartDT->format("Y-m-d H:i"); $row["startDate"] = $showStartDT->format("Y-m-d"); $row["startTime"] = $showStartDT->format("H:i"); $row["refresh"] = floatval($showStartDT->format("U.u")) - $this->epoch_now; $row["ends"] = $showEndDT->format("Y-m-d H:i"); $row["endDate"] = $showEndDT->format("Y-m-d"); $row["endTime"] = $showEndDT->format("H:i"); $row["duration"] = floatval($showEndDT->format("U.u")) - floatval($showStartDT->format("U.u")); $row["title"] = $p_item["show_name"]; $row["instance"] = intval($p_item["si_id"]); $row["image"] = ''; $this->getScheduledStatus($startsEpoch, $endsEpoch, $row); $this->contentDT = $showStartDT; return $row; }
public function updateReplayGainValueAction() { // disable layout $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $request = $this->getRequest(); $data = json_decode($request->getParam('data')); foreach ($data as $pair) { list($id, $gain) = $pair; // TODO : move this code into model -- RG $file = Application_Model_StoredFile::Recall($p_id = $id)->getPropelOrm(); $file->setDbReplayGain($gain); $file->save(); } }
private static function createScheduledEvents(&$data, $range_start, $range_end) { $utcTimeZone = new DateTimeZone("UTC"); $items = self::getItems($range_start, $range_end); foreach ($items as $item) { $showEndDateTime = new DateTime($item["show_end"], $utcTimeZone); $trackStartDateTime = new DateTime($item["start"], $utcTimeZone); $trackEndDateTime = new DateTime($item["end"], $utcTimeZone); if ($trackStartDateTime->getTimestamp() > $showEndDateTime->getTimestamp()) { //do not send any tracks that start past their show's end time continue; } if ($trackEndDateTime->getTimestamp() > $showEndDateTime->getTimestamp()) { $di = $trackStartDateTime->diff($showEndDateTime); $item["cue_out"] = $di->format("%H:%i:%s") . ".000"; $item["end"] = $showEndDateTime->format("Y-m-d H:i:s"); } if (!is_null($item['file_id'])) { //row is from "file" $media_id = $item['file_id']; $storedFile = Application_Model_StoredFile::Recall($media_id); $uri = $storedFile->getFilePath(); self::createFileScheduleEvent($data, $item, $media_id, $uri); } elseif (!is_null($item['stream_id'])) { //row is type "webstream" $media_id = $item['stream_id']; $uri = $item['url']; self::createStreamScheduleEvent($data, $item, $media_id, $uri); } else { throw new Exception("Unknown schedule type: " . print_r($item, true)); } } }
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser']; $CC_CONFIG['dsn']['password'] = $values['database']['dbpass']; $CC_CONFIG['dsn']['hostspec'] = $values['database']['host']; $CC_CONFIG['dsn']['phptype'] = 'pgsql'; $CC_CONFIG['dsn']['database'] = $values['database']['dbname']; $CC_CONFIG['soundcloud-connection-retries'] = $values['soundcloud']['connection_retries']; $CC_CONFIG['soundcloud-connection-wait'] = $values['soundcloud']['time_between_retries']; require_once $CC_CONFIG['phpDir'] . '/application/configs/constants.php'; require_once $CC_CONFIG['phpDir'] . '/application/configs/conf.php'; $CC_CONFIG['phpDir'] = $values['general']['airtime_dir']; // Ensure library/ is on include_path set_include_path(implode(PATH_SEPARATOR, array(get_include_path(), realpath($CC_CONFIG['phpDir'] . '/library')))); require_once $CC_CONFIG['phpDir'] . '/application/models/StoredFile.php'; require_once $CC_CONFIG['phpDir'] . '/application/models/Preference.php'; require_once $CC_CONFIG['phpDir'] . '/application/models/MusicDir.php'; require_once $CC_CONFIG['phpDir'] . '/application/common/OsPath.php'; set_include_path($CC_CONFIG['phpDir'] . '/library' . PATH_SEPARATOR . get_include_path()); require_once $CC_CONFIG['phpDir'] . '/application/models/Soundcloud.php'; set_include_path($CC_CONFIG['phpDir'] . "/application/models" . PATH_SEPARATOR . get_include_path()); require_once $CC_CONFIG['phpDir'] . "/library/propel/runtime/lib/Propel.php"; Propel::init($CC_CONFIG['phpDir'] . "/application/configs/airtime-conf.php"); require_once 'propel/runtime/lib/Propel.php'; Propel::init($CC_CONFIG['phpDir'] . "/application/configs/airtime-conf-production.php"); if (count($argv) != 2) { exit; } $id = $argv[1]; $file = Application_Model_StoredFile::Recall($id); // set id with -2 which is indicator for processing $file->setSoundCloudFileId(SOUNDCLOUD_PROGRESS); $file->uploadToSoundCloud();
public function getUploadToSoundcloudStatusAction() { $id = $this->_getParam('id'); $type = $this->_getParam('type'); if ($type == "show") { $show_instance = new Application_Model_ShowInstance($id); $this->view->sc_id = $show_instance->getSoundCloudFileId(); $file = $show_instance->getRecordedFile(); $this->view->error_code = $file->getSoundCloudErrorCode(); $this->view->error_msg = $file->getSoundCloudErrorMsg(); } elseif ($type == "file") { $file = Application_Model_StoredFile::Recall($id); $this->view->sc_id = $file->getSoundCloudId(); $this->view->error_code = $file->getSoundCloudErrorCode(); $this->view->error_msg = $file->getSoundCloudErrorMsg(); } else { Logging::warn("Trying to upload unknown type: {$type} with id: {$id}"); } }