SAAS-772: Send metadata to Tunein

Made Improvement so Airtime always makes a request to TuneIn every 4
minutes so TuneIn does not turn metadata off
This commit is contained in:
drigato 2015-05-25 15:37:45 -04:00
parent fc02de4920
commit 532bd1ea85
7 changed files with 59 additions and 26 deletions

View file

@ -1515,5 +1515,30 @@ class ApiController extends Zend_Controller_Action
$this->_helper->json($result);
}
/**
* This function is called from PYPO (pypofetch) every 2 minutes and updates
* metadata on TuneIn if we haven't done so in the last 4 minutes. We have
* to do this because TuneIn turns off metadata if it has not received a
* request within 5 minutes. This is necessary for long tracks > 5 minutes.
*/
public function updateMetadataOnTuneinAction()
{
if (!Application_Model_Preference::getTuneinEnabled()) {
$this->_helper->json->sendJson(array(0));
}
$lastTuneInMetadataUpdate = Application_Model_Preference::geLastTuneinMetadataUpdate();
if (time() - $lastTuneInMetadataUpdate >= 240) {
$metadata = $metadata = Application_Model_Schedule::getCurrentPlayingTrack();
if (!is_null($metadata)) {
Application_Common_TuneIn::sendMetadataToTunein(
$metadata["title"],
$metadata["artist"]
);
}
}
$this->_helper->json->sendJson(array(1));
}
}

View file

@ -315,13 +315,6 @@ class ScheduleController extends Zend_Controller_Action
{
$range = Application_Model_Schedule::GetPlayOrderRangeOld();
// If there is no current track playing update TuneIn so it doesn't
// display outdated metadata
//TODO: find a better solution for this so we don't spam the station on TuneIn
/*if (is_null($range["current"]) && Application_Model_Preference::getTuneinEnabled()) {
Application_Common_TuneIn::updateOfflineMetadata();
}*/
$show = Application_Model_Show::getCurrentShow();
/* Convert all UTC times to localtime before sending back to user. */