Merge branch 'saas-dev' into saas-landing-page

Conflicts:
	airtime_mvc/application/controllers/ApiController.php
	airtime_mvc/application/views/scripts/embed/player.phtml
This commit is contained in:
drigato 2015-05-28 13:25:18 -04:00
commit 8f8b0b7f4d
46 changed files with 1033 additions and 348 deletions

View file

@ -1,5 +1,6 @@
<?php
require_once('WidgetHelper.php');
require_once('TuneIn.php');
class ApiController extends Zend_Controller_Action
{
@ -528,6 +529,14 @@ class ApiController extends Zend_Controller_Action
$file = Application_Model_StoredFile::RecallById($file_id);
$now = new DateTime("now", new DateTimeZone("UTC"));
$file->setLastPlayedTime($now);
// Push metadata to TuneIn
if (Application_Model_Preference::getTuneinEnabled()) {
$filePropelOrm = $file->getPropelOrm();
$title = urlencode($filePropelOrm->getDbTrackTitle());
$artist = urlencode($filePropelOrm->getDbArtistName());
Application_Common_TuneIn::sendMetadataToTunein($title, $artist);
}
}
} else {
// webstream
@ -1419,5 +1428,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));
}
}