Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Naomi Aro 2012-04-27 14:42:21 +02:00
commit d7dcd03de5
10 changed files with 59 additions and 34 deletions

View File

@ -900,15 +900,19 @@ class ScheduleController extends Zend_Controller_Action
$startParam = $this->_getParam('startTime');
$endParam = $this->_getParam('endTime');
$startDateTime = new DateTime($startParam);
$endDateTime = new DateTime($endParam);
try{
$startDateTime = new DateTime($startParam);
$endDateTime = new DateTime($endParam);
$UTCStartDateTime = $startDateTime->setTimezone(new DateTimeZone('UTC'));
$UTCEndDateTime = $endDateTime->setTimezone(new DateTimeZone('UTC'));
$UTCStartDateTime = $startDateTime->setTimezone(new DateTimeZone('UTC'));
$UTCEndDateTime = $endDateTime->setTimezone(new DateTimeZone('UTC'));
$duration = $UTCEndDateTime->diff($UTCStartDateTime);
$duration = $UTCEndDateTime->diff($UTCStartDateTime);
$result = $duration->format('%r%Hh %Im');
$result = $duration->format('%r%Hh %Im');
}catch (Exception $e){
$result = "Invalid Date";
}
echo Zend_Json::encode($result);
exit();

View File

@ -46,6 +46,7 @@
</dt>
<dd id="add_show_duration-element">
<?php echo $this->element->getElement('add_show_duration') ?>
<img id="icon-loader-small" src="/css/images/loader-small.gif" style="vertical-align:middle; display:none;"/>
</dd>
<?php if($this->element->getElement('add_show_duration')->hasErrors()){ ?>
<ul class='errors'>

View File

@ -24,9 +24,12 @@
<h3>Source Streams</h3>
<ul>
<li>
<div id="scheduled_play_div" class="source-label"> Scheduled Play</div>
<div id="master_dj_div" class="source-label">
<a id="master_dj" class="source-kick-button" onclick="kickSource(this)"></a>
Master Source
</div>
<div class="line-to-switch"></div>
<a href="#" id="scheduled_play" class="source-switch-button" onclick="setSwitchListener(this);"><span><?php echo $this->scheduled_play_switch?></span></a>
<a href="#" id="master_dj" class="source-switch-button" onclick="setSwitchListener(this);"><span><?php echo $this->master_dj_switch?></span></a>
<div class="line-to-on-air"></div>
</li>
<li>
@ -39,12 +42,9 @@
<div class="line-to-on-air"></div>
</li>
<li>
<div id="master_dj_div" class="source-label">
<a id="master_dj" class="source-kick-button" onclick="kickSource(this)"></a>
Master Source
</div>
<div id="scheduled_play_div" class="source-label"> Scheduled Play</div>
<div class="line-to-switch"></div>
<a href="#" id="master_dj" class="source-switch-button" onclick="setSwitchListener(this);"><span><?php echo $this->master_dj_switch?></span></a>
<a href="#" id="scheduled_play" class="source-switch-button" onclick="setSwitchListener(this);"><span><?php echo $this->scheduled_play_switch?></span></a>
<div class="line-to-on-air"></div>
</li>
</ul>

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

View File

@ -24,6 +24,10 @@ function getDateFromString(time){
var month = parseInt(date[1], 10) -1;
var day = parseInt(date[2], 10);
if (isNaN(year) || isNaN(month) || isNaN(day)){
return null;
}
return new Date(year, month, day);
}

View File

@ -20,6 +20,11 @@ var live_dj_on_air = false;
var scheduled_play_on_air = false;
var scheduled_play_source = false;
//keep track of how many UI refreshes the ON-AIR light has been off for.
//For example, the uiUpdateInterval is every 200ms, so if onAirOffIterations
//is 25, then that means 5 seconds have gone by.
var onAirOffIterations = 0;
//var timezoneOffset = 0;
//set to "development" if we are developing :). Useful to disable alerts
@ -326,9 +331,16 @@ function parseSwitchStatus(obj){
}
function controlOnAirLight(){
if((scheduled_play_on_air && scheduled_play_source)|| live_dj_on_air || master_dj_on_air){
if ((scheduled_play_on_air && scheduled_play_source) || live_dj_on_air || master_dj_on_air) {
$('#on-air-info').attr("class", "on-air-info on");
}else{
onAirOffIterations = 0;
} else if (onAirOffIterations < 15) {
//if less than 3 seconds have gone by (< 15 executions of this function)
//then keep the ON-AIR light on. Only after at least 3 seconds have gone by,
//should we be allowed to turn it off. This is to stop the light from temporarily turning
//off between tracks: CC-3725
onAirOffIterations++;
} else {
$('#on-air-info').attr("class", "on-air-info off");
}
}

View File

@ -460,9 +460,12 @@ function setAddShowEvents() {
})
function calculateDuration(endDateTime, startDateTime){
var duration;
var loadingIcon = $('#icon-loader-small');
loadingIcon.show();
$.post("/Schedule/calculate-duration", {startTime: startDateTime, endTime: endDateTime}, function(data){
$('#add_show_duration').val(JSON.parse(data));
loadingIcon.hide();
});
}
}

View File

@ -6,7 +6,7 @@ virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
media_monitor_path="/usr/lib/airtime/media-monitor/"
media_monitor_script="MediaMonitor.py"
media_monitor_script="media_monitor.py"
api_client_path="/usr/lib/airtime/"

View File

@ -41,12 +41,15 @@ logger.info("\n\n*** Media Monitor bootup ***\n\n")
try:
fs_encoding = locale.getdefaultlocale()[1].lower()
if fs_encoding not in ['utf-8', 'utf8']:
logger.error("Filesystem encoding needs to be UTF-8. Currently '%s'. Exiting..." % fs_encoding)
sys.exit(1)
fs_encoding = locale.getdefaultlocale()[1]
if fs_encoding is not None:
if fs_encoding not in ['utf-8', 'utf8']:
logger.error("Filesystem encoding needs to be UTF-8. Currently '%s'. Exiting..." % fs_encoding)
sys.exit(1)
else:
logger.debug("Filesystem encoding: '%s'" % fs_encoding)
else:
logger.debug("Filesystem encoding: '%s'" % fs_encoding)
logger.debug("Unknown encoding")
config = AirtimeMediaConfig(logger)

View File

@ -73,7 +73,7 @@ class PypoPush(Thread):
if len(current_event_chain) > 0 and len(liquidsoap_queue_approx) == 0:
#Something is scheduled but Liquidsoap is not playing anything!
#Need to schedule it immediately..this might happen if Liquidsoap crashed.
self.modify_cue_point_of_first_link(current_event_chain)
self.modify_cue_point(current_event_chain[0])
next_media_item_chain = current_event_chain
time_until_next_play = 0
else:
@ -176,8 +176,11 @@ class PypoPush(Thread):
if problem_at_iteration is not None:
self.logger.debug("Change in chain at link %s", problem_at_iteration)
#self.modify_cue_point_of_first_link(media_chain)
self.push_to_liquidsoap(media_chain[problem_at_iteration:])
chain_to_push = media_chain[problem_at_iteration:]
if len(chain_to_push) > 0:
self.modify_cue_point(chain_to_push[0])
self.push_to_liquidsoap(chain_to_push)
"""
Compare whats in the liquidsoap_queue to the new schedule we just
@ -246,24 +249,19 @@ class PypoPush(Thread):
return chains
def modify_cue_point_of_first_link(self, chain):
def modify_cue_point(self, link):
tnow = datetime.utcnow()
link = chain[0]
link_start = datetime.strptime(link['start'], "%Y-%m-%d-%H-%M-%S")
diff_td = tnow - link_start
diff_sec = self.convert_timedelta_to_seconds(diff_td)
diff_sec = self.date_interval_to_seconds(diff_td)
if diff_sec > 0:
self.logger.debug("media item was supposed to start %s ago. Preparing to start..", diff_sec)
original_cue_in_td = timedelta(seconds=float(link['cue_in']))
link['cue_in'] = self.convert_timedelta_to_seconds(original_cue_in_td) + diff_sec
def convert_timedelta_to_seconds(self, td):
return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
link['cue_in'] = self.date_interval_to_seconds(original_cue_in_td) + diff_sec
def get_current_chain(self, chains):
tnow = datetime.utcnow()