From 881bb042a3c2e511806178597e18217938ebae5e Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 27 Jan 2011 10:07:30 -0500 Subject: [PATCH] -made pypo not schedule playlists more than 5 seconds old. -fixed up some time formatting on the now playing bar -now-playing datagrid should switch much faster between songs -updated menu --- application/configs/navigation.php | 83 +++++++++++++++--------- public/js/playlist/nowplayingdatagrid.js | 20 +++--- public/js/playlist/playlist.js | 56 ++++++++++++++-- pypo/pypo-cli.py | 15 ++++- 4 files changed, 123 insertions(+), 51 deletions(-) diff --git a/application/configs/navigation.php b/application/configs/navigation.php index f08d48139..c6a66b77e 100644 --- a/application/configs/navigation.php +++ b/application/configs/navigation.php @@ -9,12 +9,43 @@ */ $pages = array( array( - 'label' => 'Home', - 'module' => 'default', + 'label' => 'Now Playing', + 'module' => 'Nowplaying', 'controller' => 'index', 'action' => 'index', 'order' => -100 // make sure home is the first page ), + array( + 'label' => 'Schedule', + 'module' => 'default', + 'controller' => 'Schedule', + 'action' => 'index', + 'resource' => 'schedule', + 'pages' => array( + array( + 'label' => 'Add Show', + 'module' => 'default', + 'controller' => 'Schedule', + 'action' => 'add-show-dialog', + 'resource' => 'schedule' + ) + ) + ), + array( + 'label' => 'Playlist Builder', + 'module' => 'default', + 'controller' => 'Library', + 'action' => 'index', + 'resource' => 'library' + ), + array( + 'label' => 'Add Audio', + 'module' => 'default', + 'controller' => 'Plupload', + 'action' => 'plupload', + 'resource' => 'plupload' + ), + array( 'label' => 'Add User', 'module' => 'default', @@ -22,6 +53,24 @@ $pages = array( 'action' => 'add-user', 'resource' => 'user' ), + array( + 'label' => 'Configure', + 'module' => 'default', + 'controller' => 'Nowplaying', + 'pages' => array( + array( + 'label' => 'Preferences', + 'module' => 'default', + 'controller' => 'Nowplaying' + ), + array( + 'label' => 'Manage Users', + 'module' => 'default', + 'controller' => 'Nowplaying' + ) + ) + ) + /* array( 'label' => 'Media Library', 'module' => 'default', @@ -44,36 +93,8 @@ $pages = array( 'resource' => 'search' ) ) - ), - array( - 'label' => 'Now Playing', - 'module' => 'default', - 'controller' => 'Nowplaying', - 'action' => 'index' - ), - array( - 'label' => 'Schedule', - 'module' => 'default', - 'controller' => 'Schedule', - 'action' => 'index', - 'resource' => 'schedule', - 'pages' => array( - array( - 'label' => 'Add Show', - 'module' => 'default', - 'controller' => 'Schedule', - 'action' => 'add-show-dialog', - 'resource' => 'schedule' - ) - ) - ), - array( - 'label' => 'Logout', - 'module' => 'default', - 'controller' => 'Login', - 'action' => 'logout', - 'resource' => 'login' ) + */ ); // Create container from array diff --git a/public/js/playlist/nowplayingdatagrid.js b/public/js/playlist/nowplayingdatagrid.js index b2b47f9c6..2ffbfc858 100644 --- a/public/js/playlist/nowplayingdatagrid.js +++ b/public/js/playlist/nowplayingdatagrid.js @@ -1,8 +1,7 @@ +var registered = false; +var datagridData; + function getDateText(obj){ - //var str = ""; - //for (s in obj.oSettings) - // str += s + ", "; - //alert(str); var str = obj.aData[ obj.iDataColumn ]; if (str.indexOf(" ") != -1){ return changeTimePrecision(str.substring(0, str.indexOf(" "))); @@ -33,11 +32,12 @@ function changeTimePrecision(str){ } function notifySongEnd(){ - for (row in datagridData.rows){ - if (row[0] == "c") - row[0] = "p"; - if (row[0] == "n"){ - row[0] = "c"; + //alert("length " + datagridData.rows.length); + for (var i=0; i 0){ $('#previous').text(getTrackInfo(previousSongs[previousSongs.length-1])); - $('#prev-length').text(previousSongs[previousSongs.length-1].clip_length); + $('#prev-length').text(convertToHHMMSSmm(previousSongs[previousSongs.length-1].songLengthMs)); } if (currentSong.length > 0){ $('#current').text(getTrackInfo(currentSong[0])); } if (nextSongs.length > 0){ $('#next').text(getTrackInfo(nextSongs[0])); - $('#next-length').text(previousSongs[previousSongs.length-1].clip_length); + $('#next-length').text(convertToHHMMSSmm(nextSongs[0].songLengthMs)); } $('#start').empty(); @@ -200,7 +242,7 @@ function updatePlaybar(){ $('#time-elapsed').text(convertToHHMMSS(estimatedSchedulePosixTime - songStartRoughly)); $('#time-remaining').text(convertToHHMMSS(songEndRoughly - estimatedSchedulePosixTime)); - $('#song-length').text(currentSong[i].clip_length); + $('#song-length').text(convertToHHMMSSmm(currentSong[i].songLengthMs)); } /* Column 1 update */ diff --git a/pypo/pypo-cli.py b/pypo/pypo-cli.py index fb518b554..98e61c42e 100755 --- a/pypo/pypo-cli.py +++ b/pypo/pypo-cli.py @@ -117,7 +117,15 @@ class Playout: self.api_client = api_client.api_client_factory(config) self.cue_file = CueFile() self.silence_file = config["file_dir"] + 'basic/silence.mp3' + + """ + push_ahead2 MUST be < push_ahead. The difference in these two values + gives the number of seconds of the window of opportunity for the scheduler + to catch when a playlist is to be played. + """ self.push_ahead = 15 + self.push_ahead2 = 10 + self.range_updated = False @@ -578,10 +586,13 @@ class Playout: playedItems = self.load_schedule_tracker() tcoming = time.localtime(time.time() + self.push_ahead) + tcoming2 = time.localtime(time.time() + self.push_ahead2) tnow = time.localtime(time.time()) + str_tcoming_s = "%04d-%02d-%02d-%02d-%02d-%02d" % (tcoming[0], tcoming[1], tcoming[2], tcoming[3], tcoming[4], tcoming[5]) - + str_tcoming2_s = "%04d-%02d-%02d-%02d-%02d-%02d" % (tcoming2[0], tcoming2[1], tcoming2[2], tcoming2[3], tcoming2[4], tcoming2[5]) + if self.schedule == None: logger.warn('Unable to loop schedule - maybe write in progress?') logger.warn('Will try again in next loop.') @@ -589,7 +600,7 @@ class Playout: else: for pkey in self.schedule: playedFlag = (pkey in playedItems) and playedItems[pkey].get("played", 0) - if pkey[0:19] <= str_tcoming_s and not playedFlag: + if pkey[0:19] == str_tcoming_s or (pkey[0:19] < str_tcoming_s and pkey[0:19] > str_tcoming2_s and not playedFlag): logger.debug('Preparing to push playlist scheduled at: %s', pkey) playlist = self.schedule[pkey]