From 6dcc7ee2fce0d4432c058fbec613b0e749c92d72 Mon Sep 17 00:00:00 2001 From: drigato Date: Fri, 20 Feb 2015 15:50:40 -0500 Subject: [PATCH] SAAS-587: Add stream urls to station-metadata API --- .../application/controllers/ApiController.php | 1 + .../application/forms/EmbeddablePlayer.php | 2 +- airtime_mvc/application/models/StreamSetting.php | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 124b4b4d0..5f1847f77 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -637,6 +637,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::getStreamUrls(); // 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/forms/EmbeddablePlayer.php b/airtime_mvc/application/forms/EmbeddablePlayer.php index a8eb137ce..2accf23a5 100644 --- a/airtime_mvc/application/forms/EmbeddablePlayer.php +++ b/airtime_mvc/application/forms/EmbeddablePlayer.php @@ -15,7 +15,7 @@ class Application_Form_EmbeddablePlayer extends Zend_Form_SubForm $streamURL = new Zend_Form_Element_Radio('stream_url'); $urlOptions = Array(); - foreach(Application_Model_StreamSetting::getStreamUrls() as $type => $url) { + foreach(Application_Model_StreamSetting::getEnabledStreamUrls() as $type => $url) { $urlOptions[$url] = $type; } $streamURL->setMultiOptions( diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index c34c09a2e..3bdac8a31 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -62,6 +62,22 @@ class Application_Model_StreamSetting return $result ? $result : ""; } + 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; + } + /* Returns the id's of all streams that are enabled in an array. An * example of the array returned in JSON notation is ["s1", "s2", "s3"] */ public static function getEnabledStreamIds()