-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
This commit is contained in:
martin 2011-01-27 10:07:30 -05:00
parent b5a1f0fa81
commit 881bb042a3
4 changed files with 123 additions and 51 deletions

View File

@ -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

View File

@ -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<datagridData.rows.length; i++){
if (datagridData.rows[i][0] == "c")
datagridData.rows[i][0] = "p";
if (datagridData.rows[i][0] == "n"){
datagridData.rows[i][0] = "c";
break;
}
}
@ -73,8 +73,6 @@ function createDataGrid(){
} );
}
var registered = false
function init2(){
$.ajax({ url: "/Nowplaying/get-data-grid-data/format/json", dataType:"json", success:function(data){
datagridData = data.entries;

View File

@ -46,9 +46,9 @@ function convertToHHMMSS(timeInMS){
var seconds = parseInt(time / 1000);
hours = "" + hours;
minutes = "" + minutes;
seconds = "" + seconds;
hours = hours.toString();
minutes = minutes.toString();
seconds = seconds.toString();
if (hours.length == 1)
hours = "0" + hours;
@ -56,7 +56,49 @@ function convertToHHMMSS(timeInMS){
minutes = "0" + minutes;
if (seconds.length == 1)
seconds = "0" + seconds;
return "" + hours + ":" + minutes + ":" + seconds;
if (hours == "00")
return minutes + ":" + seconds;
else
return "" + hours + ":" + minutes + ":" + seconds;
}
function convertToHHMMSSmm(timeInMS){
var time = parseInt(timeInMS);
var hours = parseInt(time / 3600000);
time -= 3600000*hours;
var minutes = parseInt(time / 60000);
time -= 60000*minutes;
var seconds = parseInt(time / 1000);
time -= 1000*seconds;
var ms = parseInt(time);
hours = hours.toString();
minutes = minutes.toString();
seconds = seconds.toString();
ms = ms.toString();
if (hours.length == 1)
hours = "0" + hours;
if (minutes.length == 1)
minutes = "0" + minutes;
if (seconds.length == 1)
seconds = "0" + seconds;
if (ms.length == 3)
ms = ms.substring(0, 2);
else if (ms.length == 2)
ms = "0" + ms.substring(0,1);
else if (ms.length == 1)
ms = "00";
if (hours == "00")
return minutes + ":" + seconds + "." + ms;
else
return "" + hours + ":" + minutes + ":" + seconds+ "." + ms;
}
function convertDateToHHMMSS(epochTime){
@ -172,14 +214,14 @@ function updatePlaybar(){
$('#next-length').empty();
if (previousSongs.length > 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 */

View File

@ -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]