-fixed bug CC-1837
-show progress-bar will now update even when an audio item is not playing
This commit is contained in:
parent
be79b21c37
commit
71023a52b3
|
@ -4,10 +4,6 @@ class Application_Model_Nowplaying
|
|||
{
|
||||
|
||||
public static function GetDataGridData(){
|
||||
$timeNow = Schedule::GetSchedulerTime();
|
||||
$previous = Schedule::GetPreviousItems($timeNow, 1);
|
||||
$current = Schedule::GetCurrentlyPlaying($timeNow);
|
||||
$next = Schedule::GetNextItems($timeNow, 10);
|
||||
|
||||
$columnHeaders = array(array("sTitle"=>"type", "bVisible"=>false),
|
||||
array("sTitle"=>"Date"),
|
||||
|
@ -21,30 +17,44 @@ class Application_Model_Nowplaying
|
|||
array("sTitle"=>"Playlist"),
|
||||
array("sTitle"=>"bgcolor", "bVisible"=>false),
|
||||
array("sTitle"=>"group_id", "bVisible"=>false));
|
||||
|
||||
$timeNow = Schedule::GetSchedulerTime();
|
||||
$currentShow = Schedule::GetCurrentShow($timeNow);
|
||||
|
||||
if (count($currentShow) > 0){
|
||||
$dbRows = Schedule::GetCurrentShowGroupIDs($currentShow[0]["id"]);
|
||||
$groupIDs = array();
|
||||
|
||||
foreach ($dbRows as $row){
|
||||
array_push($groupIDs, $row["group_id"]);
|
||||
}
|
||||
}
|
||||
|
||||
$previous = Schedule::GetPreviousItems($timeNow, 1);
|
||||
$current = Schedule::GetCurrentlyPlaying($timeNow);
|
||||
$next = Schedule::GetNextItems($timeNow, 10);
|
||||
|
||||
$rows = array();
|
||||
|
||||
$current_group_id = -1;
|
||||
if (count($current) != 0){
|
||||
$current_group_id = $current[0]["group_id"];
|
||||
}
|
||||
|
||||
foreach ($previous as $item){
|
||||
$color = (count($currentShow) > 0) && in_array($item["group_id"], $groupIDs) ? "x" : "";
|
||||
array_push($rows, array("p", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
|
||||
$item["album_title"], "x" , $item["name"], ($item["group_id"] == $current_group_id ? $item["background_color"] : ""), $item["group_id"]));
|
||||
$item["album_title"], "x" , $item["name"], $color, $item["group_id"]));
|
||||
}
|
||||
|
||||
|
||||
foreach ($current as $item){
|
||||
array_push($rows, array("c", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
|
||||
$item["album_title"], "x" , $item["name"], $item["background_color"], $item["group_id"]));
|
||||
$item["album_title"], "x" , $item["name"], "", $item["group_id"]));
|
||||
}
|
||||
|
||||
foreach ($next as $item){
|
||||
$color = (count($currentShow) > 0) && in_array($item["group_id"], $groupIDs) ? "x" : "";
|
||||
array_push($rows, array("n", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
|
||||
$item["album_title"], "x" , $item["name"], ($item["group_id"] == $current_group_id ? $item["background_color"] : ""), $item["group_id"]));
|
||||
$item["album_title"], "x" , $item["name"], $color, $item["group_id"]));
|
||||
}
|
||||
$data = array("columnHeaders"=>$columnHeaders, "rows"=>$rows);
|
||||
|
||||
return array("columnHeaders"=>$columnHeaders, "rows"=>$rows);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -472,24 +472,23 @@ class Schedule {
|
|||
}
|
||||
|
||||
$timeNow = Schedule::GetSchedulerTime();
|
||||
return array("schedulerTime"=>gmdate("Y-m-d H:i:s"),"previous"=>Schedule::GetPreviousItems($timeNow),
|
||||
return array("schedulerTime"=>gmdate("Y-m-d H:i:s"),
|
||||
"previous"=>Schedule::GetPreviousItems($timeNow),
|
||||
"current"=>Schedule::GetCurrentlyPlaying($timeNow),
|
||||
"next"=>Schedule::GetNextItems($timeNow),
|
||||
"showStartEndTime"=>Schedule::GetCurrentShow($timeNow),
|
||||
"timezone"=> date("T"),
|
||||
"timezoneOffset"=> date("Z"));
|
||||
}
|
||||
|
||||
public static function GetPreviousItems($timeNow, $prevCount = 1){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.group_id, sdt.start_time, sdt.end_time, showt.background_color"
|
||||
." FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt, $CC_CONFIG[showSchedule] sst, $CC_CONFIG[showDays] sdt, $CC_CONFIG[showTable] showt"
|
||||
$sql = "SELECT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.group_id"
|
||||
." FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt"
|
||||
." WHERE st.ends < TIMESTAMP '$timeNow'"
|
||||
." AND st.ends > (TIMESTAMP '$timeNow' - INTERVAL '24 hours')"
|
||||
." AND st.playlist_id = pt.id"
|
||||
." AND st.file_id = ft.id"
|
||||
." AND st.group_id = sst.group_id"
|
||||
." AND sdt.show_id = sst.show_id"
|
||||
." AND showt.id = sst.show_id"
|
||||
." ORDER BY st.starts DESC"
|
||||
." LIMIT $prevCount";
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
|
@ -499,39 +498,59 @@ class Schedule {
|
|||
public static function GetCurrentlyPlaying($timeNow){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
$sql = "SELECT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.group_id, sdt.start_time, sdt.end_time, showt.background_color"
|
||||
$sql = "SELECT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.group_id"
|
||||
." FROM $CC_CONFIG[scheduleTable] st,"
|
||||
."$CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt, $CC_CONFIG[showSchedule] sst, $CC_CONFIG[showDays] sdt, $CC_CONFIG[showTable] showt"
|
||||
."$CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt"
|
||||
." WHERE st.starts < TIMESTAMP '$timeNow'"
|
||||
." AND st.ends > TIMESTAMP '$timeNow'"
|
||||
." AND st.playlist_id = pt.id"
|
||||
." AND st.file_id = ft.id"
|
||||
." AND st.group_id = sst.group_id"
|
||||
." AND sdt.show_id = sst.show_id"
|
||||
." AND showt.id = sst.show_id";
|
||||
." AND st.file_id = ft.id";
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public static function GetNextItems($timeNow, $nextCount = 1) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.group_id, sdt.start_time, sdt.end_time, showt.background_color"
|
||||
." FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt, $CC_CONFIG[showSchedule] sst, $CC_CONFIG[showDays] sdt, $CC_CONFIG[showTable] showt"
|
||||
$sql = "SELECT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.group_id"
|
||||
." FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt"
|
||||
." WHERE st.starts > TIMESTAMP '$timeNow'"
|
||||
." AND st.ends < (TIMESTAMP '$timeNow' + INTERVAL '24 hours')"
|
||||
." AND st.playlist_id = pt.id"
|
||||
." AND st.file_id = ft.id"
|
||||
." AND st.group_id = sst.group_id"
|
||||
." AND sdt.show_id = sst.show_id"
|
||||
." AND showt.id = sst.show_id"
|
||||
." ORDER BY st.starts"
|
||||
." LIMIT $nextCount";
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public static function GetStatus() {
|
||||
public static function GetCurrentShow($timeNow) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
$timestamp = preg_split("/ /", $timeNow);
|
||||
$date = $timestamp[0];
|
||||
$time = $timestamp[1];
|
||||
|
||||
$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"
|
||||
." WHERE sd.show_id = s.id"
|
||||
." AND sd.first_show <= DATE '$date'"
|
||||
." AND sd.start_time <= TIME '$time'"
|
||||
." AND sd.last_show > DATE '$date'"
|
||||
." AND sd.end_time > TIME '$time'";
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public static function GetCurrentShowGroupIDs($showID){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
$sql = "SELECT group_id"
|
||||
." FROM $CC_CONFIG[showSchedule]"
|
||||
." WHERE show_id = $showID";
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
<body>
|
||||
<h1>An error occurred</h1>
|
||||
<h2><?php echo $this->message ?></h2>
|
||||
<h2><?php echo "test".APPLICATION_ENV ?></h2>
|
||||
|
||||
<?php if ('development' == APPLICATION_ENV): ?>
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
<?php
|
||||
|
||||
//error_reporting(E_ALL|E_STRICT);
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 'on');
|
||||
|
||||
// Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
var estimatedSchedulePosixTime = -1;
|
||||
|
||||
var localRemoteTimeOffset = -1;
|
||||
var estimatedSchedulePosixTime = null;
|
||||
var localRemoteTimeOffset = null;
|
||||
|
||||
var previousSongs = new Array();
|
||||
var currentSong = new Array();
|
||||
|
@ -16,6 +15,7 @@ var songEndFunc;
|
|||
var showStartPosixTime = 0;
|
||||
var showEndPosixTime = 0;
|
||||
var showLengthMs = 1;
|
||||
var currentShowName = "";
|
||||
|
||||
/* boolean flag to let us know if we should prepare to execute a function
|
||||
* that flips the playlist to the next song. This flags purpose is to
|
||||
|
@ -50,23 +50,18 @@ function getTrackInfo(song){
|
|||
}
|
||||
|
||||
function secondsTimer(){
|
||||
if (localRemoteTimeOffset != null){
|
||||
var date = new Date();
|
||||
if (localRemoteTimeOffset != -1)
|
||||
estimatedSchedulePosixTime = date.getTime() - localRemoteTimeOffset;
|
||||
updateProgressBarValue();
|
||||
|
||||
}
|
||||
|
||||
function updateGlobalValues(obj){
|
||||
showStartPosixTime = obj.showStartPosixTime;
|
||||
showEndPosixTime = obj.showEndPosixTime;
|
||||
showLengthMs = showEndPosixTime - showStartPosixTime;
|
||||
}
|
||||
setTimeout(secondsTimer, uiUpdateInterval);
|
||||
}
|
||||
|
||||
function newSongStart(){
|
||||
nextSongPrepare = true;
|
||||
currentSong[0] = nextSongs.shift();
|
||||
updateGlobalValues(currentSong[0]);
|
||||
//updateGlobalValues(currentSong[0]);
|
||||
updatePlaybar();
|
||||
|
||||
notifySongEndListener();
|
||||
|
@ -74,7 +69,6 @@ function newSongStart(){
|
|||
|
||||
/* Called every "uiUpdateInterval" mseconds. */
|
||||
function updateProgressBarValue(){
|
||||
if (estimatedSchedulePosixTime != -1){
|
||||
if (showStartPosixTime != 0){
|
||||
var showPercentDone = (estimatedSchedulePosixTime - showStartPosixTime)/showLengthMs*100;
|
||||
if (showPercentDone < 0 || showPercentDone > 100){
|
||||
|
@ -105,8 +99,6 @@ function updateProgressBarValue(){
|
|||
}
|
||||
|
||||
updatePlaybar();
|
||||
}
|
||||
setTimeout(secondsTimer, uiUpdateInterval);
|
||||
}
|
||||
|
||||
function updatePlaybar(){
|
||||
|
@ -149,9 +141,8 @@ function updatePlaybar(){
|
|||
|
||||
/* Column 1 update */
|
||||
$('#playlist').text("Current Show:");
|
||||
for (var i=0; i<currentSong.length; i++){
|
||||
$('#playlist').text(currentSong[i].name);
|
||||
}
|
||||
$('#playlist').text(currentShowName);
|
||||
|
||||
$('#show-length').empty();
|
||||
if (estimatedSchedulePosixTime < showEndPosixTime){
|
||||
$('#show-length').text(convertDateToHHMMSS(showStartPosixTime) + " - " + convertDateToHHMMSS(showEndPosixTime));
|
||||
|
@ -167,20 +158,16 @@ function calcAdditionalData(currentItem, bUpdateGlobalValues){
|
|||
currentItem[i].songEndPosixTime = convertDateToPosixTime(currentItem[i].ends);
|
||||
currentItem[i].songLengthMs = currentItem[i].songEndPosixTime - currentItem[i].songStartPosixTime;
|
||||
|
||||
currentItem[i].showStartPosixTime = convertDateToPosixTime(currentItem[i].starts.substring(0, currentItem[i].starts.indexOf(" ")) + " " + currentItem[i].start_time);
|
||||
currentItem[i].showEndPosixTime = convertDateToPosixTime(currentItem[i].starts.substring(0, currentItem[i].starts.indexOf(" ")) + " " + currentItem[i].end_time);
|
||||
|
||||
//check if there is a rollover past midnight
|
||||
if (currentItem[i].start_time > currentItem[i].end_time){
|
||||
//start_time is greater than end_time, so we rolled through midnight.
|
||||
currentItem[i].showEndPosixTime += (1000*3600*24); //add 24 hours
|
||||
}
|
||||
|
||||
currentItem[i].showLengthMs = currentItem[i].showEndPosixTime - currentItem[i].showStartPosixTime;
|
||||
|
||||
if (bUpdateGlobalValues){
|
||||
updateGlobalValues(currentItem[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function updateGlobalValues(obj){
|
||||
if (obj.showStartEndTime.length > 0){
|
||||
showStartPosixTime = convertDateToPosixTime(obj.showStartEndTime[0].start_timestamp);
|
||||
showEndPosixTime = convertDateToPosixTime(obj.showStartEndTime[0].end_timestamp);
|
||||
showLengthMs = showEndPosixTime - showStartPosixTime;
|
||||
currentShowName = obj.showStartEndTime[0].name;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,17 +181,28 @@ function parseItems(obj){
|
|||
currentSong = obj.current;
|
||||
nextSongs = obj.next;
|
||||
|
||||
calcAdditionalData(previousSongs, false);
|
||||
calcAdditionalData(currentSong, true);
|
||||
calcAdditionalData(nextSongs, false);
|
||||
updateGlobalValues(obj);
|
||||
|
||||
if (estimatedSchedulePosixTime == -1){
|
||||
calcAdditionalData(previousSongs);
|
||||
calcAdditionalData(currentSong);
|
||||
calcAdditionalData(nextSongs);
|
||||
|
||||
if (localRemoteTimeOffset == null){
|
||||
var date = new Date();
|
||||
localRemoteTimeOffset = date.getTime() - schedulePosixTime;
|
||||
estimatedSchedulePosixTime = schedulePosixTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getScheduleFromServerDebug(){
|
||||
$.ajax({ url: "/Schedule/get-current-playlist/format/json", dataType:"text", success:function(data){
|
||||
alert(data);
|
||||
}});
|
||||
setTimeout(getScheduleFromServer, serverUpdateInterval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getScheduleFromServer(){
|
||||
$.ajax({ url: "/Schedule/get-current-playlist/format/json", dataType:"json", success:function(data){
|
||||
parseItems(data.entries);
|
||||
|
@ -212,12 +210,14 @@ function getScheduleFromServer(){
|
|||
setTimeout(getScheduleFromServer, serverUpdateInterval);
|
||||
}
|
||||
|
||||
|
||||
function init() {
|
||||
//begin producer "thread"
|
||||
getScheduleFromServer();
|
||||
//getScheduleFromServerDebug();
|
||||
|
||||
//begin consumer "thread"
|
||||
updateProgressBarValue();
|
||||
secondsTimer();
|
||||
}
|
||||
|
||||
function popup(mylink){
|
||||
|
@ -233,6 +233,5 @@ function popup(mylink){
|
|||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
//initialize the playlist bar in the included playlist.js
|
||||
init();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue