-synchronize
This commit is contained in:
parent
fa106b1da1
commit
4bdcba83e2
|
@ -71,7 +71,7 @@ $pages = array(
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'label' => 'Test',
|
'label' => 'Now Playing',
|
||||||
'module' => 'default',
|
'module' => 'default',
|
||||||
'controller' => 'Schedule',
|
'controller' => 'Schedule',
|
||||||
'action' => 'get-scheduler-time'
|
'action' => 'get-scheduler-time'
|
||||||
|
|
|
@ -306,7 +306,7 @@ class LocStor extends BasicStor {
|
||||||
{
|
{
|
||||||
// $res = $this->existsAudioClip($sessid, $gunid);
|
// $res = $this->existsAudioClip($sessid, $gunid);
|
||||||
// if(PEAR::isError($res)) return $res;
|
// if(PEAR::isError($res)) return $res;
|
||||||
$media = StoredFile::RecallByGunid($gunid)
|
$media = StoredFile::RecallByGunid($gunid);
|
||||||
$id = $media->getGunid();
|
$id = $media->getGunid();
|
||||||
if (is_null($id)) {
|
if (is_null($id)) {
|
||||||
return PEAR::raiseError(
|
return PEAR::raiseError(
|
||||||
|
|
|
@ -442,60 +442,41 @@ class Schedule {
|
||||||
}
|
}
|
||||||
|
|
||||||
$timeNow = Schedule::GetSchedulerTime();
|
$timeNow = Schedule::GetSchedulerTime();
|
||||||
$currentSong = Schedule::getCurrentlyPlaying();
|
return array("schedulerTime"=>$timeNow,"previous"=>Schedule::GetPreviousItems($timeNow),
|
||||||
return array("schedulerTime"=>$timeNow,"previous"=>Schedule::getPreviousItems($timeNow),
|
"current"=>Schedule::GetCurrentlyPlaying($timeNow),
|
||||||
"current"=>Schedule::getCurrentlyPlaying($timeNow),
|
"next"=>Schedule::GetNextItems($timeNow));
|
||||||
"next"=>Schedule::getNextItems($timeNow));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function GetPreviousItems($timeNow, $prevCount = 1){
|
private static function GetPreviousItems($timeNow, $prevCount = 1){
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
$sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"]
|
$sql = "SELECT * FROM $CC_CONFIG[scheduleTable], $CC_CONFIG[filesTable]"
|
||||||
." WHERE (starts < TIMESTAMP '$timeNow')"
|
." WHERE ($CC_CONFIG[scheduleTable].ends < TIMESTAMP '$timeNow')"
|
||||||
." ORDER BY id"
|
." AND ($CC_CONFIG[scheduleTable].file_id = $CC_CONFIG[filesTable].id)"
|
||||||
|
." ORDER BY $CC_CONFIG[scheduleTable].id"
|
||||||
." LIMIT $prevCount";
|
." LIMIT $prevCount";
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$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;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function GetCurrentlyPlaying($timeNow){
|
private static function GetCurrentlyPlaying($timeNow){
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
$sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"]
|
$sql = "SELECT * FROM $CC_CONFIG[scheduleTable], $CC_CONFIG[filesTable]"
|
||||||
." WHERE (starts < TIMESTAMP '$timeNow') "
|
." WHERE ($CC_CONFIG[scheduleTable].starts < TIMESTAMP '$timeNow')"
|
||||||
." AND (ends > TIMESTAMP '$timeNow')";
|
." AND ($CC_CONFIG[scheduleTable].ends > TIMESTAMP '$timeNow')"
|
||||||
|
." AND ($CC_CONFIG[scheduleTable].file_id = $CC_CONFIG[filesTable].id)";
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$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;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function GetNextItems($timeNow, $nextCount = 1) {
|
private static function GetNextItems($timeNow, $nextCount = 1) {
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
$sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"]
|
$sql = "SELECT * FROM $CC_CONFIG[scheduleTable], $CC_CONFIG[filesTable]"
|
||||||
." WHERE (starts > TIMESTAMP '$timeNow')"
|
." WHERE ($CC_CONFIG[scheduleTable].starts > TIMESTAMP '$timeNow')"
|
||||||
." ORDER BY id"
|
." AND ($CC_CONFIG[scheduleTable].file_id = $CC_CONFIG[filesTable].id)"
|
||||||
|
." ORDER BY $CC_CONFIG[scheduleTable].id"
|
||||||
." LIMIT $nextCount";
|
." LIMIT $nextCount";
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$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;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,21 @@
|
||||||
var day = s.substring(8, 10);
|
var day = s.substring(8, 10);
|
||||||
var hour = s.substring(11, 13);
|
var hour = s.substring(11, 13);
|
||||||
var minute = s.substring(14, 16);
|
var minute = s.substring(14, 16);
|
||||||
var sec = s.substring(17);
|
var sec = 0;
|
||||||
|
var msec = 0;
|
||||||
return Date.UTC(year, month, day, hour, minute, sec, 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 schedulePosixTime;
|
||||||
|
|
||||||
|
var previousSong;
|
||||||
var currentSong;
|
var currentSong;
|
||||||
var nextSong;
|
var nextSong;
|
||||||
|
|
||||||
|
@ -40,17 +48,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentPlayingItem(currentItem){
|
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 songStartPosixTime = convertDateToPosixTime(currentItem.starts);
|
||||||
var songEndPosixTime = convertDateToPosixTime(currentItem.ends);
|
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){
|
function parseItems(obj){
|
||||||
schedulePosixTime = convertDateToPosixTime(obj.schedulerTime);
|
schedulePosixTime = convertDateToPosixTime(obj.schedulerTime);
|
||||||
|
if (obj.previous.length > 0){
|
||||||
|
previousSong = getCurrentPlayingItem(obj.previous[0]);
|
||||||
|
$("#previous").html(obj.schedulerTime + " " + schedulePosixTime + "<br>" +
|
||||||
|
obj.previous[0].clip_length + " " + previousSong.songLengthMs + "<br>" +
|
||||||
|
obj.previous[0].starts + " " + previousSong.songStartPosixTime + "<br>" +
|
||||||
|
obj.previous[0].ends + " " + previousSong.songEndPosixTime + "<br>" +
|
||||||
|
obj.previous[0].name + "<br>");
|
||||||
|
}
|
||||||
if (obj.current.length > 0){
|
if (obj.current.length > 0){
|
||||||
currentSong = getCurrentPlayingItem(obj.current[0]);
|
currentSong = getCurrentPlayingItem(obj.current[0]);
|
||||||
|
$("#current").html(obj.schedulerTime + " " + schedulePosixTime + "<br>" +
|
||||||
|
obj.current[0].clip_length + " " + currentSong.songLengthMs + "<br>" +
|
||||||
|
obj.current[0].starts + " " + currentSong.songStartPosixTime + "<br>" +
|
||||||
|
obj.current[0].ends + " " + currentSong.songEndPosixTime + "<br>" +
|
||||||
|
obj.current[0].name + "<br>");
|
||||||
}
|
}
|
||||||
if (obj.next.length > 0){
|
if (obj.next.length > 0){
|
||||||
nextSong = getCurrentPlayingItem(obj.next[0]);
|
nextSong = getCurrentPlayingItem(obj.next[0]);
|
||||||
|
$("#next").html(obj.schedulerTime + " " + schedulePosixTime + "<br>" +
|
||||||
|
obj.next[0].clip_length + " " + nextSong.songLengthMs + "<br>" +
|
||||||
|
obj.next[0].starts + " " + nextSong.songStartPosixTime + "<br>" +
|
||||||
|
obj.next[0].ends + " " + nextSong.songEndPosixTime + "<br>" +
|
||||||
|
obj.next[0].name + "<br>");
|
||||||
}
|
}
|
||||||
updateProgressBarValue();
|
updateProgressBarValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getScheduleFromServer(){
|
function getScheduleFromServer(){
|
||||||
$.ajax({ url: "/Schedule/get-current-playlist/format/json", dataType:"json", success:function(data){
|
$.ajax({ url: "/Schedule/get-current-playlist/format/json", dataType:"json", success:function(data){
|
||||||
|
//alert(data);
|
||||||
parseItems(data.entries);
|
parseItems(data.entries);
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
@ -82,5 +102,9 @@
|
||||||
getScheduleFromServer();
|
getScheduleFromServer();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<div id="previous" style="background: blue;"></div>
|
||||||
|
<div id="current" style="background: white;"></div>
|
||||||
<span class="progressBar" id="spaceused1">0%</span>
|
<span class="progressBar" id="spaceused1">0%</span>
|
||||||
|
<div id="next" style="background: yellow;"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -23,9 +23,6 @@ def remove_user(username):
|
||||||
|
|
||||||
os.system("deluser --remove-home " + username + " > /dev/null")
|
os.system("deluser --remove-home " + username + " > /dev/null")
|
||||||
|
|
||||||
#pypo group appears to be deleted when removing user.
|
|
||||||
#os.system("delgroup " + username)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.system("python ./pypo-stop.py")
|
os.system("python ./pypo-stop.py")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue