diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 63c24d14a..f8017eb43 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -209,6 +209,44 @@ class ApiController extends Zend_Controller_Action } } + public function onAirLightAction() + { + $this->view->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + + $result = array(); + $result["on_air_light"] = false; + $result["on_air_light_expected_status"] = false; + $result["station_down"] = false; + + $range = Application_Model_Schedule::GetPlayOrderRange(); + + $isItemCurrentlyPlaying = !is_null($range["current"]) && + $range["current"]["media_item_played"] && + count($range["currentShow"]) > 0; + + if ($isItemCurrentlyPlaying || + Application_Model_Preference::GetSourceSwitchStatus("live_dj") == "on" || + Application_Model_Preference::GetSourceSwitchStatus("master_dj") == "on") + { + $result["on_air_light_expected_status"] = true; + } + + if (($isItemCurrentlyPlaying && + Application_Model_Preference::GetSourceSwitchStatus("scheduled_play") == "on")|| + Application_Model_Preference::GetSourceSwitchStatus("live_dj") == "on" || + Application_Model_Preference::GetSourceSwitchStatus("master_dj") == "on") + { + $result["on_air_light"] = true; + } + + if ($result["on_air_light_expected_status"] != $result["on_air_light"]) { + $result["station_down"] = true; + } + + echo isset($_GET['callback']) ? $_GET['callback'].'('.json_encode($result).')' : json_encode($result); + } + /** * Retrieve the currently playing show as well as upcoming shows. * Number of shows returned and the time interval in which to