diff --git a/application/configs/navigation.php b/application/configs/navigation.php
index a5de95b29..42ef8aab9 100644
--- a/application/configs/navigation.php
+++ b/application/configs/navigation.php
@@ -71,7 +71,7 @@ $pages = array(
)
),
array(
- 'label' => 'Test',
+ 'label' => 'Now Playing',
'module' => 'default',
'controller' => 'Schedule',
'action' => 'get-scheduler-time'
diff --git a/application/models/LocStor.php b/application/models/LocStor.php
index fa0956f3b..f7d2e0cbe 100644
--- a/application/models/LocStor.php
+++ b/application/models/LocStor.php
@@ -306,7 +306,7 @@ class LocStor extends BasicStor {
{
// $res = $this->existsAudioClip($sessid, $gunid);
// if(PEAR::isError($res)) return $res;
- $media = StoredFile::RecallByGunid($gunid)
+ $media = StoredFile::RecallByGunid($gunid);
$id = $media->getGunid();
if (is_null($id)) {
return PEAR::raiseError(
diff --git a/application/models/Schedule.php b/application/models/Schedule.php
index f54844024..5daa2c513 100644
--- a/application/models/Schedule.php
+++ b/application/models/Schedule.php
@@ -442,60 +442,41 @@ class Schedule {
}
$timeNow = Schedule::GetSchedulerTime();
- $currentSong = Schedule::getCurrentlyPlaying();
- return array("schedulerTime"=>$timeNow,"previous"=>Schedule::getPreviousItems($timeNow),
- "current"=>Schedule::getCurrentlyPlaying($timeNow),
- "next"=>Schedule::getNextItems($timeNow));
+ return array("schedulerTime"=>$timeNow,"previous"=>Schedule::GetPreviousItems($timeNow),
+ "current"=>Schedule::GetCurrentlyPlaying($timeNow),
+ "next"=>Schedule::GetNextItems($timeNow));
}
private static function GetPreviousItems($timeNow, $prevCount = 1){
global $CC_CONFIG, $CC_DBC;
- $sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"]
- ." WHERE (starts < TIMESTAMP '$timeNow')"
- ." ORDER BY id"
+ $sql = "SELECT * FROM $CC_CONFIG[scheduleTable], $CC_CONFIG[filesTable]"
+ ." WHERE ($CC_CONFIG[scheduleTable].ends < TIMESTAMP '$timeNow')"
+ ." AND ($CC_CONFIG[scheduleTable].file_id = $CC_CONFIG[filesTable].id)"
+ ." ORDER BY $CC_CONFIG[scheduleTable].id"
." LIMIT $prevCount";
$rows = $CC_DBC->GetAll($sql);
- foreach ($rows as &$row) {
- $row["count"] = "1";
- $row["playlistId"] = $row["playlist_id"];
- $row["start"] = $row["starts"];
- $row["end"] = $row["ends"];
- $row["id"] = $row["group_id"];
- }
return $rows;
}
private static function GetCurrentlyPlaying($timeNow){
global $CC_CONFIG, $CC_DBC;
- $sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"]
- ." WHERE (starts < TIMESTAMP '$timeNow') "
- ." AND (ends > TIMESTAMP '$timeNow')";
+ $sql = "SELECT * FROM $CC_CONFIG[scheduleTable], $CC_CONFIG[filesTable]"
+ ." WHERE ($CC_CONFIG[scheduleTable].starts < TIMESTAMP '$timeNow')"
+ ." AND ($CC_CONFIG[scheduleTable].ends > TIMESTAMP '$timeNow')"
+ ." AND ($CC_CONFIG[scheduleTable].file_id = $CC_CONFIG[filesTable].id)";
$rows = $CC_DBC->GetAll($sql);
- foreach ($rows as &$row) {
- $row["count"] = "1";
- $row["playlistId"] = $row["playlist_id"];
- $row["start"] = $row["starts"];
- $row["end"] = $row["ends"];
- $row["id"] = $row["group_id"];
- }
return $rows;
}
private static function GetNextItems($timeNow, $nextCount = 1) {
global $CC_CONFIG, $CC_DBC;
- $sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"]
- ." WHERE (starts > TIMESTAMP '$timeNow')"
- ." ORDER BY id"
+ $sql = "SELECT * FROM $CC_CONFIG[scheduleTable], $CC_CONFIG[filesTable]"
+ ." WHERE ($CC_CONFIG[scheduleTable].starts > TIMESTAMP '$timeNow')"
+ ." AND ($CC_CONFIG[scheduleTable].file_id = $CC_CONFIG[filesTable].id)"
+ ." ORDER BY $CC_CONFIG[scheduleTable].id"
." LIMIT $nextCount";
$rows = $CC_DBC->GetAll($sql);
- foreach ($rows as &$row) {
- $row["count"] = "1";
- $row["playlistId"] = $row["playlist_id"];
- $row["start"] = $row["starts"];
- $row["end"] = $row["ends"];
- $row["id"] = $row["group_id"];
- }
return $rows;
}
diff --git a/application/views/scripts/schedule/get-scheduler-time.phtml b/application/views/scripts/schedule/get-scheduler-time.phtml
index 8cff686e4..03e1d2a0f 100644
--- a/application/views/scripts/schedule/get-scheduler-time.phtml
+++ b/application/views/scripts/schedule/get-scheduler-time.phtml
@@ -6,13 +6,21 @@
var day = s.substring(8, 10);
var hour = s.substring(11, 13);
var minute = s.substring(14, 16);
- var sec = s.substring(17);
-
- return Date.UTC(year, month, day, hour, minute, sec, 0);
+ var sec = 0;
+ var msec = 0;
+ if (s.length >= 20){
+ sec = s.substring(17, 19);
+ msec = s.substring(20);
+ } else {
+ sec = s.substring(17);
+ }
+
+ return Date.UTC(year, month, day, hour, minute, sec, msec);
}
var schedulePosixTime;
+ var previousSong;
var currentSong;
var nextSong;
@@ -40,17 +48,10 @@
}
function getCurrentPlayingItem(currentItem){
- var clipLength = currentItem.clip_length;
- var clHours = parseInt(clipLength.substring(0, 2));
- var clMinutes = parseInt(clipLength.substring(3, 5));
- var clSeconds = parseInt(clipLength.substring(6, 8));
- var clMs = parseInt(clipLength.substring(9));
-
- var songLengthMs = clMs + clSeconds*1000 + clMinutes*60*1000 + clHours*60*60*1000;
var songStartPosixTime = convertDateToPosixTime(currentItem.starts);
var songEndPosixTime = convertDateToPosixTime(currentItem.ends);
- return {songLengthMs:songLengthMs, songStartPosixTime:songStartPosixTime, songEndPosixTime:songEndPosixTime};
+ return {songLengthMs:songEndPosixTime-songStartPosixTime, songStartPosixTime:songStartPosixTime, songEndPosixTime:songEndPosixTime};
}
@@ -62,17 +63,36 @@
function parseItems(obj){
schedulePosixTime = convertDateToPosixTime(obj.schedulerTime);
+ if (obj.previous.length > 0){
+ previousSong = getCurrentPlayingItem(obj.previous[0]);
+ $("#previous").html(obj.schedulerTime + " " + schedulePosixTime + "
" +
+ obj.previous[0].clip_length + " " + previousSong.songLengthMs + "
" +
+ obj.previous[0].starts + " " + previousSong.songStartPosixTime + "
" +
+ obj.previous[0].ends + " " + previousSong.songEndPosixTime + "
" +
+ obj.previous[0].name + "
");
+ }
if (obj.current.length > 0){
currentSong = getCurrentPlayingItem(obj.current[0]);
+ $("#current").html(obj.schedulerTime + " " + schedulePosixTime + "
" +
+ obj.current[0].clip_length + " " + currentSong.songLengthMs + "
" +
+ obj.current[0].starts + " " + currentSong.songStartPosixTime + "
" +
+ obj.current[0].ends + " " + currentSong.songEndPosixTime + "
" +
+ obj.current[0].name + "
");
}
if (obj.next.length > 0){
nextSong = getCurrentPlayingItem(obj.next[0]);
+ $("#next").html(obj.schedulerTime + " " + schedulePosixTime + "
" +
+ obj.next[0].clip_length + " " + nextSong.songLengthMs + "
" +
+ obj.next[0].starts + " " + nextSong.songStartPosixTime + "
" +
+ obj.next[0].ends + " " + nextSong.songEndPosixTime + "
" +
+ obj.next[0].name + "
");
}
updateProgressBarValue();
}
function getScheduleFromServer(){
$.ajax({ url: "/Schedule/get-current-playlist/format/json", dataType:"json", success:function(data){
+ //alert(data);
parseItems(data.entries);
}});
}
@@ -82,5 +102,9 @@
getScheduleFromServer();
});
+