diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php
index 8f3a5f482..dbc06eec2 100644
--- a/application/controllers/ScheduleController.php
+++ b/application/controllers/ScheduleController.php
@@ -195,7 +195,10 @@ class ScheduleController extends Zend_Controller_Action
public function viewPlaylistAction()
{
- //TODO: insert code for datagrid
+ $this->view->headScript()->appendFile('/js/playlist/playlist.js','text/javascript');
+ $this->view->headScript()->appendFile('/js/progressbar/jquery.progressbar.min.js','text/javascript');
+
+ $this->_helper->viewRenderer->setResponseSegment('nowplaying');
}
public function getCurrentPlaylistAction()
diff --git a/application/layouts/scripts/layout.phtml b/application/layouts/scripts/layout.phtml
index 8e0fada9b..768cda63b 100644
--- a/application/layouts/scripts/layout.phtml
+++ b/application/layouts/scripts/layout.phtml
@@ -3,27 +3,15 @@
- Airtime
+ Airtime!!
headScript() ?>
headLink() ?>
+layout()->nowplaying ?>
navigation()->menu()->setRenderInvisible(true) ?>
-layout()->content ?>
-
+layout()->content ?>
diff --git a/application/views/scripts/schedule/view-playlist.phtml b/application/views/scripts/schedule/view-playlist.phtml
index 51580a791..804b2acdd 100644
--- a/application/views/scripts/schedule/view-playlist.phtml
+++ b/application/views/scripts/schedule/view-playlist.phtml
@@ -1,9 +1,21 @@
-
-
-
-
+
+
+
+
Show:
+
Playlist:
+
Host:
+
+
+
+
Previous:
+
Current:
+
Upcoming:
+
+
+
+
Start: End:
+
diff --git a/public/js/playlist/playlist.js b/public/js/playlist/playlist.js
index bddca6f60..d00849391 100644
--- a/public/js/playlist/playlist.js
+++ b/public/js/playlist/playlist.js
@@ -1,154 +1,146 @@
-(function($) {
- // jQuery plugin definition
- $.fn.playlistViewer = function(params) {
- var cc = this;
- cc.estimatedSchedulePosixTime = -1;
- cc.schedulePosixTime;
+var estimatedSchedulePosixTime = -1;
+var schedulePosixTime;
- cc.previousSongs;
- cc.currentSong;
- cc.nextSongs;
-
- cc.currentElem;
+var previousSongs;
+var currentSong;
+var nextSongs;
- // traverse all nodes
- return this.each(function() {
- // express a single node as a jQuery object
- cc.currentElem = $(this);
-
- var prevDiv = document.createElement('div');
- prevDiv.setAttribute("id", "previous");
- $(cc.currentElem).append(prevDiv);
-
- var currParentDiv = document.createElement('div');
- $(cc.currentElem).append(currParentDiv);
-
- var currDiv = document.createElement('div');
- currDiv.setAttribute("id", "current");
- $(currParentDiv).append(currDiv);
-
- var nextDiv = document.createElement('div');
- nextDiv.setAttribute("id", "progressbar");
- $(currParentDiv).append(nextDiv);
-
- var nextDiv = document.createElement('div');
- nextDiv.setAttribute("id", "next");
- $(cc.currentElem).append(nextDiv);
-
- $('#progressbar').progressBar(0);
+var currentElem;
- getScheduleFromServer();
- updateProgressBarValue();
- });
+function init(elemID) {
+ var currentElem = $("#" + elemID).attr("style", "z-index: 1; width: 100%; left: 0px; right: 0px; bottom: 0px; color: white; min-height: 100px; background-color: #cc3300;");
+
+ $('#progressbar').progressBar(0);
- 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);
- }
+ getScheduleFromServer();
+ updateProgressBarValue();
+
+}
- return Date.UTC(year, month, day, hour, minute, sec, msec);
- }
+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);
+ }
- function secondsTimer(){
- cc.estimatedSchedulePosixTime += 1000;
- updateProgressBarValue();
- }
+ return Date.UTC(year, month, day, hour, minute, sec, msec);
+}
- function updateProgressBarValue(){
- if (cc.estimatedSchedulePosixTime != -1){
- if (cc.currentSong.length > 0){
- var percentDone = (cc.estimatedSchedulePosixTime - cc.currentSong[0].songStartPosixTime)/cc.currentSong[0].songLengthMs*100;
- if (percentDone <= 100){
- $('#progressbar').progressBar(percentDone);
- } else {
- if (cc.nextSongs.length > 0){
- cc.currentSong[0] = cc.nextSongs.shift();
- } else {
- cc.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.
- cc.estimatedSchedulePosixTime = cc.schedulePosixTime;
- }
- } else
- $('#progressbar').progressBar(0);
- updatePlaylist();
- }
- setTimeout(secondsTimer, 1000);
- }
+function secondsTimer(){
+ estimatedSchedulePosixTime += 1000;
+ updateProgressBarValue();
+}
- function createPlaylistElementString(song){
- return "Start time: " + song.starts + "
" +
- "End time: " + song.ends + "
" +
- "Clip length: " + song.clip_length + "
" +
- "Name: " + song.name + "
";
- }
+/* 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 updatePlaylist(){
- $('#previous').empty();
- $('#current').empty();
- $('#next').empty();
- for (var i=0; i 0){
- var nextItem = obj.next[0];
- }
- }
+function calcAdditionalData(currentItem){
+ for (var i=0; i 0){
+ var nextItem = obj.next[0];
+ }
+}
- if (cc.estimatedSchedulePosixTime == -1)
- cc.estimatedSchedulePosixTime = cc.schedulePosixTime;
+function parseItems(obj){
+ schedulePosixTime = convertDateToPosixTime(obj.schedulerTime);
- cc.previousSongs = obj.previous;
- cc.currentSong = obj.current;
- cc.nextSongs = obj.next;
+ if (estimatedSchedulePosixTime == -1)
+ estimatedSchedulePosixTime = schedulePosixTime;
- calcAdditionalData(cc.previousSongs);
- calcAdditionalData(cc.currentSong);
- calcAdditionalData(cc.nextSongs);
- }
+ previousSongs = obj.previous;
+ currentSong = obj.current;
+ nextSongs = obj.next;
- function getScheduleFromServer(){
- $.ajax({ url: "/Schedule/get-current-playlist/format/json", dataType:"json", success:function(data){
- parseItems(data.entries);
- }});
- setTimeout(getScheduleFromServer, 5000);
- }
+ calcAdditionalData(previousSongs);
+ calcAdditionalData(currentSong);
+ calcAdditionalData(nextSongs);
+}
- };
-})(jQuery);
+function getScheduleFromServer(){
+ $.ajax({ url: "/Schedule/get-current-playlist/format/json", dataType:"json", success:function(data){
+ parseItems(data.entries);
+ }});
+ setTimeout(getScheduleFromServer, 5000);
+}
+
+$(document).ready(function() {
+ init("nowplayingbar");
+});
diff --git a/pypo/pypo-cli.py b/pypo/pypo-cli.py
index 9f05d6a58..fb518b554 100755
--- a/pypo/pypo-cli.py
+++ b/pypo/pypo-cli.py
@@ -695,8 +695,8 @@ class Playout:
#Return the time as a floating point number expressed in seconds since the epoch, in UTC.
epoch_now = time.time()
- logger.debug("Epoch start: "+ str(epoch_start))
- logger.debug("Epoch now: "+ str(epoch_now))
+ logger.debug("Epoch start: " + str(epoch_start))
+ logger.debug("Epoch now: " + str(epoch_now))
sleep_time = epoch_start - epoch_now;