This commit is contained in:
parent
65cc694a90
commit
a99a742bdc
|
@ -27,7 +27,7 @@ class Application_Model_Nowplaying
|
|||
$arrayIndexOffset = 0;
|
||||
|
||||
if ($n < 2)
|
||||
return;
|
||||
return $rows;
|
||||
|
||||
for ($i=1; $i<$n; $i++){
|
||||
if ($rows[$i-1][3] != $rows[$i][2])
|
||||
|
|
|
@ -587,11 +587,15 @@ class Schedule {
|
|||
public static function GetNextShow($timeNow) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
$sql = "SELECT current_date + sd.start_time as start_timestamp, current_date + sd.end_time as end_timestamp, s.name, s.id"
|
||||
." FROM $CC_CONFIG[showDays] sd, $CC_CONFIG[showTable] s"
|
||||
$datetime = explode(" ", $timeNow);
|
||||
|
||||
$sql = "SELECT *, (current_date + start_time) as start_timestamp, (current_date + end_time) as end_timestamp FROM "
|
||||
." $CC_CONFIG[showDays] sd, $CC_CONFIG[showTable] s"
|
||||
." WHERE sd.show_id = s.id"
|
||||
." AND (sd.first_show + sd.start_time) >= TIMESTAMP '$timeNow'"
|
||||
." ORDER BY (sd.first_show + sd.start_time)"
|
||||
." AND ((sd.last_show + sd.end_time) > TIMESTAMP '$timeNow' OR sd.last_show = NULL)"
|
||||
." AND TIME '$datetime[1]' < sd.start_time "
|
||||
." AND sd.day = EXTRACT(DOW FROM TIMESTAMP '$timeNow')"
|
||||
." ORDER BY sd.start_time"
|
||||
." LIMIT 1";
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
|
|
|
@ -104,17 +104,23 @@ function updateProgressBarValue(){
|
|||
|
||||
//calculate how much time left to next song if there is any
|
||||
if (nextSongs.length > 0 && nextSongPrepare){
|
||||
if (nextSongs[0].songStartPosixTime - estimatedSchedulePosixTime < serverUpdateInterval){
|
||||
var diff = nextSongs[0].songStartPosixTime - estimatedSchedulePosixTime;
|
||||
if (diff < serverUpdateInterval && diff >= 0){
|
||||
nextSongPrepare = false;
|
||||
setTimeout(newSongStart, nextSongs[0].songStartPosixTime - estimatedSchedulePosixTime);
|
||||
setTimeout(newSongStart, diff);
|
||||
} else if (diff < 0){
|
||||
alert ("Warning: estimatedSchedulePosixTime > songStartPosixTime");
|
||||
}
|
||||
}
|
||||
|
||||
//calculate how much time left to next show if there is any
|
||||
if (nextShow.length > 0 && nextShowPrepare){
|
||||
if (nextShow[0].showStartPosixTime - estimatedSchedulePosixTime < serverUpdateInterval){
|
||||
var diff = nextShow[0].showStartPosixTime - estimatedSchedulePosixTime;
|
||||
if (diff < serverUpdateInterval && diff >= 0){
|
||||
nextShowPrepare = false;
|
||||
setTimeout(nextShowStart, nextShow[0].showStartPosixTime - estimatedSchedulePosixTime);
|
||||
setTimeout(nextShowStart, diff);
|
||||
} else if (diff < 0){
|
||||
alert ("Warning: estimatedSchedulePosixTime > showStartPosixTime");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,6 +191,12 @@ function calcAdditionalShowData(show){
|
|||
if (show.length > 0){
|
||||
show[0].showStartPosixTime = convertDateToPosixTime(show[0].start_timestamp);
|
||||
show[0].showEndPosixTime = convertDateToPosixTime(show[0].end_timestamp);
|
||||
|
||||
//hack to fix case where show end is next day, but we have it set
|
||||
//as the same day.
|
||||
if (show[0].showEndPosixTime - show[0].showStartPosixTime < 0)
|
||||
show[0].showEndPosixTime += 1000*3600*24;
|
||||
|
||||
show[0].showLengthMs = show[0].showEndPosixTime - show[0].showStartPosixTime;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue