From f6d5b34cca21493931e8243476a5dbecd0685221 Mon Sep 17 00:00:00 2001 From: drigato Date: Tue, 7 Apr 2015 17:49:21 -0400 Subject: [PATCH] Embed player - code review fixes --- .../application/controllers/ApiController.php | 2 +- .../EmbeddableplayerController.php | 17 +++- .../application/forms/EmbeddablePlayer.php | 19 +++-- .../application/models/StreamSetting.php | 16 ---- .../scripts/embeddableplayer/embed-code.phtml | 83 ++++++++++++++----- 5 files changed, 89 insertions(+), 48 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 80429db08..5ecd5f1da 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -523,7 +523,7 @@ class ApiController extends Zend_Controller_Action $result["description"] = Application_Model_Preference::GetStationDescription(); $result["timezone"] = Application_Model_Preference::GetDefaultTimezone(); $result["locale"] = Application_Model_Preference::GetDefaultLocale(); - $result["enabled_stream_urls"] = Application_Model_StreamSetting::getEnabledStreamUrls(); + $result["stream_data"] = Application_Model_StreamSetting::getEnabledStreamData(); // used by caller to determine if the airtime they are running or widgets in use is out of date. $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; diff --git a/airtime_mvc/application/controllers/EmbeddableplayerController.php b/airtime_mvc/application/controllers/EmbeddableplayerController.php index 3552ee47e..43e8be2d5 100644 --- a/airtime_mvc/application/controllers/EmbeddableplayerController.php +++ b/airtime_mvc/application/controllers/EmbeddableplayerController.php @@ -30,18 +30,29 @@ class EmbeddablePlayerController extends Zend_Controller_Action } + /** + * This is the action that is called to insert the player onto a web page. + * It passes all the js and css files to the view, as well as all the + * stream customization information. + * + * The view for this action contains all the inline javascript needed to + * create the player. + */ public function embedCodeAction() { $this->view->layout()->disableLayout(); + $CC_CONFIG = Config::getConfig(); + $request = $this->getRequest(); - $this->view->css = Application_Common_HTTPHelper::getStationUrl() . "css/embeddable-player.css"; - $this->view->mrp_js = Application_Common_HTTPHelper::getStationUrl() . "js/airtime/embeddableplayer/mrp.js"; + $this->view->css = Application_Common_HTTPHelper::getStationUrl() . "css/embeddable-player.css?".$CC_CONFIG['airtime_version']; + $this->view->mrp_js = Application_Common_HTTPHelper::getStationUrl() . "js/airtime/embeddableplayer/mrp.js?".$CC_CONFIG['airtime_version']; $this->view->jquery = Application_Common_HTTPHelper::getStationUrl() . "js/libs/jquery-1.10.2.js"; $this->view->muses_swf = Application_Common_HTTPHelper::getStationUrl() . "js/airtime/embeddableplayer/muses.swf"; $this->view->metadata_api_url = Application_Common_HTTPHelper::getStationUrl() . "api/live-info"; - $this->view->station_name = Application_Model_Preference::GetStationName(); + $this->view->station_name = addslashes(Application_Model_Preference::GetStationName()); + $stream = $request->getParam('stream'); $streamData = Application_Model_StreamSetting::getEnabledStreamData(); $availableMobileStreams = array(); diff --git a/airtime_mvc/application/forms/EmbeddablePlayer.php b/airtime_mvc/application/forms/EmbeddablePlayer.php index e5086716a..ca8ca45c9 100644 --- a/airtime_mvc/application/forms/EmbeddablePlayer.php +++ b/airtime_mvc/application/forms/EmbeddablePlayer.php @@ -1,5 +1,7 @@ 'form/embeddableplayer.phtml')) )); + /* We will use this option in the future $displayTrackMetadata = new Zend_Form_Element_Checkbox('player_display_track_metadata'); $displayTrackMetadata->setValue(true); $displayTrackMetadata->setLabel(_('Display track metadata?')); $this->addElement($displayTrackMetadata); + */ $streamMode = new Zend_Form_Element_Radio('player_stream_mode'); $streamMode->setLabel(_('Select Stream:')); $streamMode->setMultiOptions( array( - "auto" => "Auto detect the most appropriate stream to use.", - "manual" => "Select a stream:" + "auto" => _("Auto detect the most appropriate stream to use."), + "manual" => _("Select a stream:") ) ); $streamMode->setValue("auto"); @@ -30,19 +34,20 @@ class Application_Form_EmbeddablePlayer extends Zend_Form_SubForm foreach(Application_Model_StreamSetting::getEnabledStreamData() as $stream => $data) { $urlOptions[$stream] = strtoupper($data["codec"])." - ".$data["bitrate"]."kbps"; if ($data["mobile"]) { - $urlOptions[$stream] .= " - Mobile friendly"; + $urlOptions[$stream] .= _(" - Mobile friendly"); } - if ($data["codec"] == "opus") { + if ($data["codec"] == OPUS) { $opusStreamCount += 1; - $urlOptions[$stream] .=" - The player does not support Opus streams."; + $urlOptions[$stream] .= _(" - The player does not support Opus streams."); } } $streamURL->setMultiOptions( $urlOptions ); + // Set default value to the first non-opus stream we find foreach ($urlOptions as $o => $v) { - if (strpos(strtolower($v), "opus") !== false) { + if (strpos(strtolower($v), OPUS) !== false) { continue; } else { $streamURL->setValue($o); @@ -62,7 +67,7 @@ class Application_Form_EmbeddablePlayer extends Zend_Form_SubForm $this->addElement($embedSrc); $previewLabel = new Zend_Form_Element_Text('player_preview_label'); - $previewLabel->setLabel("Preview:"); + $previewLabel->setLabel(_("Preview:")); $this->addElement($previewLabel); } diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index c51995d6d..688ddc397 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -65,22 +65,6 @@ class Application_Model_StreamSetting return $result ? $result : $default; } - public static function getEnabledStreamUrls() - { - $urls = Array(); - $streamIds = Application_Model_StreamSetting::getEnabledStreamIds(); - foreach ($streamIds as $id) { - $prefix = $id."_"; - $streamData = Application_Model_StreamSetting::getStreamData($id); - $host = $streamData[$prefix."host"]; - $port = $streamData[$prefix."port"]; - $mount = $streamData[$prefix."mount"]; - $type = $streamData[$prefix."type"]; - $urls[$type] = "http://$host:$port/$mount"; - } - return $urls; - } - public static function getEnabledStreamData() { $streams = Array(); diff --git a/airtime_mvc/application/views/scripts/embeddableplayer/embed-code.phtml b/airtime_mvc/application/views/scripts/embeddableplayer/embed-code.phtml index 66117609a..f079a4564 100644 --- a/airtime_mvc/application/views/scripts/embeddableplayer/embed-code.phtml +++ b/airtime_mvc/application/views/scripts/embeddableplayer/embed-code.phtml @@ -7,6 +7,17 @@ + @@ -219,7 +259,8 @@ - + + -->
@@ -240,7 +282,6 @@
Powered by Airtime Pro -