-changes to now playing bar
This commit is contained in:
parent
5173674714
commit
c8b7cffdc6
|
@ -53,6 +53,8 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
$view = $this->getResource('view');
|
||||
$view->headScript()->appendFile('/js/libs/jquery-1.4.4.min.js','text/javascript');
|
||||
$view->headScript()->appendFile('/js/libs/jquery-ui-1.8.8.custom.min.js','text/javascript');
|
||||
$view->headScript()->appendFile('/js/progressbar/jquery.progressbar.min.js','text/javascript');
|
||||
$view->headScript()->appendFile('/js/playlist/playlist.js','text/javascript');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,14 +11,13 @@ class NowplayingController extends Zend_Controller_Action
|
|||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->headScript()->appendFile('/js/playlist/playlist.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.min.js','text/javascript');
|
||||
$this->view->headScript()->appendFile('/js/progressbar/jquery.progressbar.min.js','text/javascript');
|
||||
|
||||
|
||||
$this->view->headLink()->appendStylesheet('/css/datatables/css/demo_page.css');
|
||||
$this->view->headLink()->appendStylesheet('/css/datatables/css/demo_table.css');
|
||||
|
||||
$this->_helper->viewRenderer->setResponseSegment('nowplaying');
|
||||
//$this->_helper->viewRenderer->setResponseSegment('nowplaying');
|
||||
}
|
||||
|
||||
public function getDataGridDataAction()
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</head>
|
||||
<body>
|
||||
|
||||
<div id="nowplayingbar"><?php echo $this->layout()->nowplaying ?></div>
|
||||
<div id="nowplayingbar"><?= $this->partial('partialviews/header.phtml') ?></div>
|
||||
<div id="nav"><?php echo $this->navigation()->menu()->setRenderInvisible(true) ?></div>
|
||||
|
||||
<div id="content"><?php echo $this->layout()->content ?></div>
|
||||
|
|
|
@ -21,14 +21,14 @@ class Application_Model_Nowplaying
|
|||
$rows = array();
|
||||
|
||||
foreach ($previous as $item){
|
||||
array_push($rows, array(substr($item["starts"], 0, strpos($item["starts"], " ")), $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
|
||||
array_push($rows, array($item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
|
||||
$item["album_title"], "x" , "y"));
|
||||
}
|
||||
|
||||
|
||||
foreach ($current as $item){
|
||||
array_push($rows, array($item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
|
||||
$item["album_title"], "x" , "y"));
|
||||
$item["album_title"], "x" , "y"));
|
||||
}
|
||||
|
||||
foreach ($next as $item){
|
||||
|
|
|
@ -502,9 +502,10 @@ class Schedule {
|
|||
|
||||
public static function GetNextItems($timeNow, $nextCount = 1) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT * FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft"
|
||||
$sql = "SELECT *, pt.name as playlistName FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt"
|
||||
." WHERE (st.starts > TIMESTAMP '$timeNow')"
|
||||
." AND (st.file_id = ft.id)"
|
||||
." AND (st.playlist_id = pt.id)"
|
||||
." ORDER BY st.starts"
|
||||
." LIMIT $nextCount";
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
|
|
|
@ -1,29 +1,42 @@
|
|||
<div id='col0' style='float:left; width: 10%; height: 100%;'>
|
||||
<div>Listen</div>
|
||||
<div>Volume</div>
|
||||
</div>
|
||||
|
||||
<div id='col1' style='float:left; width: 25%; height: 100%;'>
|
||||
<div>Show: <span id='show'></span></div>
|
||||
<div>Playlist: <span id='playlist'></span></div>
|
||||
<div>Host: <span id='host'></span></div>
|
||||
</div>
|
||||
|
||||
<div id='col2' style='float:left; width: 30%; height: 100%;'>
|
||||
<div>Previous: <span id='previous'></span></div>
|
||||
<div>Current: <span id='current'></span></div>
|
||||
<div>Upcoming: <span id='next'></span></div>
|
||||
</div>
|
||||
|
||||
<div id='list0' style='float:left; width: 35%; height: 100%;'></div>
|
||||
<div>Start: <span id='start'></span></div>
|
||||
<div>End: <span id='end'></span></div>
|
||||
<div><span id='progressbar'></span> <span id='songposition'></span> | <span id='songlength'></span></div>
|
||||
</div>
|
||||
<div id='demo'></div>
|
||||
<script>
|
||||
function getDateText(obj){
|
||||
var str = obj.aData[ obj.iDataColumn ];
|
||||
if (str.indexOf(" ") != -1){
|
||||
return changeTimePrecision(str.substring(0, str.indexOf(" ")));
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function getTimeText(obj){
|
||||
var str = obj.aData[ obj.iDataColumn ];
|
||||
if (str.indexOf(" ") != -1){
|
||||
return changeTimePrecision(str.substring(str.indexOf(" ")+1));
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function changeTimePrecisionInit(obj){
|
||||
var str = obj.aData[ obj.iDataColumn ];
|
||||
return changeTimePrecision(str);
|
||||
}
|
||||
|
||||
function changeTimePrecision(str){
|
||||
if (str.indexOf(".") != -1){
|
||||
if (str.length - str.indexOf(".") > 2)
|
||||
var extraLength = str.length - str.indexOf(".") -3;
|
||||
return str.substring(0, str.length - extraLength);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function createDataGrid(obj){
|
||||
|
||||
obj.columnHeaders[0]["fnRender"] = getDateText;
|
||||
obj.columnHeaders[1]["fnRender"] = getTimeText;
|
||||
obj.columnHeaders[2]["fnRender"] = getTimeText;
|
||||
obj.columnHeaders[3]["fnRender"] = changeTimePrecisionInit;
|
||||
|
||||
$('#demo').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table>' );
|
||||
$('#example').dataTable( {
|
||||
"bSort" : false,
|
||||
|
@ -38,15 +51,12 @@ function createDataGrid(obj){
|
|||
|
||||
function init2(){
|
||||
$.ajax({ url: "/Nowplaying/get-data-grid-data/format/json", dataType:"json", success:function(data){
|
||||
//alert(data);
|
||||
createDataGrid(data.entries);
|
||||
}});
|
||||
//setTimeout(init2, 5000);
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
//initialize the playlist bar in the included playlist.js
|
||||
init("nowplayingbar");
|
||||
init2();
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<div id='col0' style='float:left; width: 10%; height: 100%;'>
|
||||
<div><a href="Schedule" onClick="return popup(this)">Listen</a></div>
|
||||
</div>
|
||||
|
||||
<div id='col1' style='float:left; width: 25%; height: 100%;'>
|
||||
<div>Show: <span id='show'></span></div>
|
||||
<div>Playlist: <span id='playlist'></span></div>
|
||||
<div>Host: <span id='host'></span></div>
|
||||
</div>
|
||||
|
||||
<div id='col2' style='float:left; width: 30%; height: 100%;'>
|
||||
<div>Previous: <span id='previous'></span></div>
|
||||
<div>Current: <span id='current'></span></div>
|
||||
<div>Upcoming: <span id='next'></span></div>
|
||||
</div>
|
||||
|
||||
<div id='list0' style='float:left; width: 35%; height: 100%;'></div>
|
||||
<div>Start: <span id='start'></span></div>
|
||||
<div>End: <span id='end'></span></div>
|
||||
<div><span id='progressbar'></span> <span id='songposition'></span> | <span id='songlength'></span></div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function popup(mylink){
|
||||
if (!window.focus)
|
||||
return true;
|
||||
var href;
|
||||
if (typeof(mylink) == 'string')
|
||||
href=mylink;
|
||||
else
|
||||
href=mylink.href;
|
||||
window.open(href, "player", 'width=400,height=200,scrollbars=yes');
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
//initialize the playlist bar in the included playlist.js
|
||||
init("nowplayingbar");
|
||||
});
|
||||
</script>
|
|
@ -1,71 +1,16 @@
|
|||
var estimatedSchedulePosixTime = -1;
|
||||
var schedulePosixTime;
|
||||
|
||||
var previousSongs;
|
||||
var currentSong;
|
||||
var nextSongs;
|
||||
var currentRemoteTimeOffset;
|
||||
|
||||
var previousSongs = new Array();
|
||||
var currentSong = new Array();
|
||||
var nextSongs = new Array();
|
||||
|
||||
var currentElem;
|
||||
|
||||
function init(elemID) {
|
||||
var currentElem = $("#" + elemID).attr("style", "z-index: 1; width: 100%; left: 0px; right: 0px; bottom: 0px; color: black; min-height: 100px; background-color: #FEF1B5;");
|
||||
|
||||
$('#progressbar').progressBar(0, {showText : false});
|
||||
var updateInterval = 5000;
|
||||
|
||||
getScheduleFromServer();
|
||||
updateProgressBarValue();
|
||||
|
||||
}
|
||||
|
||||
function convertDateToPosixTime(s){
|
||||
var year = s.substring(0, 4);
|
||||
var month = s.substring(5, 7);
|
||||
var day = s.substring(8, 10);
|
||||
var hour = s.substring(11, 13);
|
||||
var minute = s.substring(14, 16);
|
||||
var sec = s.substring(17, 19);
|
||||
var msec = 0;
|
||||
if (s.length >= 20){
|
||||
msec = s.substring(20);
|
||||
}
|
||||
|
||||
return Date.UTC(year, month, day, hour, minute, sec, msec);
|
||||
}
|
||||
|
||||
function secondsTimer(){
|
||||
estimatedSchedulePosixTime += 1000;
|
||||
updateProgressBarValue();
|
||||
}
|
||||
|
||||
/* Called every 1 second. */
|
||||
function updateProgressBarValue(){
|
||||
if (estimatedSchedulePosixTime != -1){
|
||||
if (currentSong.length > 0){
|
||||
var percentDone = (estimatedSchedulePosixTime - currentSong[0].songStartPosixTime)/currentSong[0].songLengthMs*100;
|
||||
if (percentDone <= 100){
|
||||
$('#progressbar').progressBar(percentDone);
|
||||
} else {
|
||||
if (nextSongs.length > 0){
|
||||
currentSong[0] = nextSongs.shift();
|
||||
} else {
|
||||
currentSong = new Array();
|
||||
}
|
||||
$('#progressbar').progressBar(0);
|
||||
//at the end of each song we are updating the
|
||||
//server time we have been estimating client-side
|
||||
//with the real server time.
|
||||
estimatedSchedulePosixTime = schedulePosixTime;
|
||||
}
|
||||
} else
|
||||
$('#progressbar').progressBar(0);
|
||||
updatePlaylist();
|
||||
}
|
||||
setTimeout(secondsTimer, 1000);
|
||||
}
|
||||
|
||||
function getTrackInfo(song){
|
||||
return song.track_title + " - " + song.artist_name + " - " + song.album_title;
|
||||
}
|
||||
|
||||
function convertToHHMMSS(timeInMS){
|
||||
var time = parseInt(timeInMS);
|
||||
|
@ -91,19 +36,89 @@ function convertToHHMMSS(timeInMS){
|
|||
return "" + hours + ":" + minutes + ":" + seconds;
|
||||
}
|
||||
|
||||
function convertDateToPosixTime(s){
|
||||
var year = s.substring(0, 4);
|
||||
var month = s.substring(5, 7);
|
||||
var day = s.substring(8, 10);
|
||||
var hour = s.substring(11, 13);
|
||||
var minute = s.substring(14, 16);
|
||||
var sec = s.substring(17, 19);
|
||||
var msec = 0;
|
||||
if (s.length >= 20){
|
||||
msec = s.substring(20);
|
||||
}
|
||||
|
||||
return Date.UTC(year, month, day, hour, minute, sec, msec);
|
||||
}
|
||||
|
||||
function getTrackInfo(song){
|
||||
var str = "";
|
||||
|
||||
if (song.track_title != null)
|
||||
str += song.track_title;
|
||||
if (song.artist_name != null)
|
||||
str += " - " + song.artist_name;
|
||||
if (song.album_title != null)
|
||||
str += " - " + song.album_title;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
function secondsTimer(){
|
||||
var date = new Date();
|
||||
estimatedSchedulePosixTime = date.getTime() - currentRemoteTimeOffset;
|
||||
updateProgressBarValue();
|
||||
}
|
||||
|
||||
/* Called every 1 second. */
|
||||
function updateProgressBarValue(){
|
||||
if (estimatedSchedulePosixTime != -1){
|
||||
if (currentSong.length > 0){
|
||||
var percentDone = (estimatedSchedulePosixTime - currentSong[0].songStartPosixTime)/currentSong[0].songLengthMs*100;
|
||||
if (percentDone <= 100){
|
||||
$('#progressbar').progressBar(percentDone);
|
||||
} else {
|
||||
if (nextSongs.length > 0){
|
||||
currentSong[0] = nextSongs.shift();
|
||||
} else {
|
||||
currentSong = new Array();
|
||||
}
|
||||
$('#progressbar').progressBar(0);
|
||||
}
|
||||
} else {
|
||||
$('#progressbar').progressBar(0);
|
||||
|
||||
//calculate how much time left to next song if there is any
|
||||
if (nextSongs.length > 0){
|
||||
if (nextSongs[0].songStartPosixTime - estimatedSchedulePosixTime < updateInterval){
|
||||
setTimeout(temp, nextSongs[0].songStartPosixTime - estimatedSchedulePosixTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
updatePlaylist();
|
||||
}
|
||||
setTimeout(secondsTimer, 200);
|
||||
}
|
||||
|
||||
function temp(){
|
||||
currentSong[0] = nextSongs[0];
|
||||
updatePlaylist();
|
||||
}
|
||||
|
||||
function updatePlaylist(){
|
||||
/* Column 0 update */
|
||||
$('#listen');
|
||||
$('#volume');
|
||||
|
||||
|
||||
/* Column 1 update */
|
||||
$('#show').empty();
|
||||
$('#playlist').empty();
|
||||
$('#host').empty();
|
||||
for (var i=0; i<currentSong.length; i++){
|
||||
$('#show').append(currentSong[i].show);
|
||||
//alert (currentSong[i].playlistname);
|
||||
//$('#show').append(currentSong[i].show);
|
||||
$('#playlist').append(currentSong[i].playlistname);
|
||||
$('#host').append(currentSong[i].creator);
|
||||
//$('#host').append(currentSong[i].creator);
|
||||
}
|
||||
|
||||
/* Column 2 update */
|
||||
|
@ -141,18 +156,15 @@ function calcAdditionalData(currentItem){
|
|||
}
|
||||
}
|
||||
|
||||
function prepareNextPlayingItem(obj){
|
||||
if (obj.next.length > 0){
|
||||
var nextItem = obj.next[0];
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(obj){
|
||||
schedulePosixTime = convertDateToPosixTime(obj.schedulerTime);
|
||||
|
||||
if (estimatedSchedulePosixTime == -1)
|
||||
if (estimatedSchedulePosixTime == -1){
|
||||
var date = new Date();
|
||||
currentRemoteTimeOffset = date.getTime() - schedulePosixTime;
|
||||
estimatedSchedulePosixTime = schedulePosixTime;
|
||||
|
||||
}
|
||||
|
||||
previousSongs = obj.previous;
|
||||
currentSong = obj.current;
|
||||
nextSongs = obj.next;
|
||||
|
@ -166,5 +178,15 @@ function getScheduleFromServer(){
|
|||
$.ajax({ url: "/Schedule/get-current-playlist/format/json", dataType:"json", success:function(data){
|
||||
parseItems(data.entries);
|
||||
}});
|
||||
setTimeout(getScheduleFromServer, 5000);
|
||||
setTimeout(getScheduleFromServer, updateInterval);
|
||||
}
|
||||
|
||||
function init(elemID) {
|
||||
var currentElem = $("#" + elemID).attr("style", "z-index: 1; width: 100%; left: 0px; right: 0px; bottom: 0px; color: black; min-height: 100px; background-color: #FEF1B5;");
|
||||
|
||||
$('#progressbar').progressBar(0, {showText : false});
|
||||
|
||||
getScheduleFromServer();
|
||||
updateProgressBarValue();
|
||||
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ echo "Creating new playlist '$playlistName'...";
|
|||
$pl = new Playlist();
|
||||
$pl->create($playlistName);
|
||||
|
||||
/*
|
||||
|
||||
// Add a media clip
|
||||
$mediaFile = StoredFile::findByOriginalName("ACDC_-_Back_In_Black-sample.ogg");
|
||||
if (is_null($mediaFile)) {
|
||||
|
@ -54,7 +54,6 @@ if (is_null($mediaFile)) {
|
|||
}
|
||||
}
|
||||
$pl->addAudioClip($mediaFile->getId());
|
||||
*/
|
||||
|
||||
$mediaFile = StoredFile::findByOriginalName("Peter_Rudenko_-_Opening.mp3");
|
||||
if (is_null($mediaFile)) {
|
||||
|
@ -69,6 +68,20 @@ if (is_null($mediaFile)) {
|
|||
$pl->addAudioClip($mediaFile->getId());
|
||||
echo "done.\n";
|
||||
|
||||
$mediaFile = StoredFile::findByOriginalName("Manolo Camp - Morning Coffee.mp3");
|
||||
if (is_null($mediaFile)) {
|
||||
echo "Adding test audio clip to the database.\n";
|
||||
$v = array("filepath" => __DIR__."/../../audio_samples/OpSound/Manolo Camp - Morning Coffee.mp3");
|
||||
$mediaFile = StoredFile::Insert($v);
|
||||
if (PEAR::isError($mediaFile)) {
|
||||
var_dump($mediaFile);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
$pl->addAudioClip($mediaFile->getId());
|
||||
echo "done.\n";
|
||||
|
||||
|
||||
//$pl2 = Playlist::findPlaylistByName("pypo_playlist_test");
|
||||
//var_dump($pl2);
|
||||
|
||||
|
@ -91,7 +104,8 @@ echo "done.\n";
|
|||
|
||||
// Schedule the playlist for two minutes from now
|
||||
echo "Scheduling new playlist...\n";
|
||||
$playTime = date("Y-m-d H:i:s", time()+(60*$minutesFromNow));
|
||||
//$playTime = date("Y-m-d H:i:s", time()+(60*$minutesFromNow));
|
||||
$playTime = date("Y-m-d H:i:s", time()+(20*$minutesFromNow));
|
||||
$scheduleGroup = new ScheduleGroup();
|
||||
$scheduleGroup->add($playTime, null, $pl->getId());
|
||||
|
||||
|
|
Loading…
Reference in New Issue