/** * default action of this controller: proxy media data */ public function index_action() { $url = Request::get('url'); $media_proxy = new MediaProxy(); $config = Config::GetInstance(); $modified_since = NULL; if (!Seminar_Session::is_current_session_authenticated() || $config->getValue('LOAD_EXTERNAL_MEDIA') != 'proxy') { throw new AccessDeniedException(); } if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $modified_since = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']); } ini_set('default_socket_timeout', 5); $this->render_nothing(); //stop output buffering started in Trails_Dispatcher::dispatch() while (ob_get_level()) { ob_end_clean(); } try { $media_proxy->readURL($url, $modified_since); } catch (MediaProxyException $ex) { header($ex->getMessage()); } }
<?php # # This is the media player proxy redirect - it may not be part of the regular controller because of conflicts # with HTTP_Download setting its own headers. the routing for this resides in the .htaccess file # //configure app and validate the user require_once dirname(__FILE__) . '/../apps/client/lib/ProxyBootstrap.class.php'; //create a new media player object $mediaplayer = new MediaProxy($_REQUEST['unique_song_id']); //add options if (isset($_REQUEST['target_bitrate']) && !empty($_REQUEST['target_bitrate'])) { $mediaplayer->setTargetBitrate($_REQUEST['target_bitrate']); } if (isset($_REQUEST['target_format']) && !empty($_REQUEST['target_format'])) { $mediaplayer->setTargetFormat($_REQUEST['target_format']); } if (isset($_REQUEST['is_icy_response']) && !empty($_REQUEST['is_icy_response'])) { $mediaplayer->setIsIcyResponse($_REQUEST['is_icy_response']); } if (isset($_REQUEST['start_time']) && !empty($_REQUEST['start_time'])) { $mediaplayer->setStartTime($_REQUEST['start_time']); } //shut down the symfony context so it doesn't lock up symfony while streaming global $context; $context->shutdown(); unset($context); //play the media file $mediaplayer->play();