#2361 HTML UI: 'Now Playing' doesn't refresh at the end of a playlist

This commit is contained in:
sebastian 2010-04-07 15:59:47 +00:00
parent 649f62e058
commit 0f78e887bc
6 changed files with 465 additions and 266 deletions

View File

@ -30,7 +30,7 @@ form {
color: #000; color: #000;
} }
.copyright a{ .copyright a {
color: blue; color: blue;
} }
@ -785,13 +785,13 @@ table.scheduler_month .scala .scala_in {
/* ############################################# MASTERPALETTE ################################# */ /* ############################################# MASTERPALETTE ################################# */
#masterpalette{ #masterpalette{
padding-left: 0px; padding-left: 0px;
border-left: 0px; border-left: 0px;
background: #fff; background: #fff;
width: 990px; width: 990px;
height: 140px; height: 140px;
#border-bottom: 1px solid #ccc; #border-bottom: 1px solid #ccc;
} }
table.masterpalette td{ table.masterpalette td{
padding: 5px 5px 5px 5px; padding: 5px 5px 5px 5px;
@ -800,31 +800,30 @@ table.masterpalette td{
} }
#logo { #logo {
padding-top: 20px; padding-top: 20px;
padding-bottom: 20px; padding-bottom: 20px;
padding-left: 20px; padding-left: 20px;
padding-right: 20px; padding-right: 20px;
} }
#time { #time {
padding-top: 5px; padding-top: 5px;
background: #EBF1F8;
background: #EBF1F8; padding-bottom: 10px;
padding-bottom: 10px; padding-left: 10px;
padding-left: 10px; padding-right: 5px;
padding-right: 5px; line-height: 14pt;
line-height: 14pt; font-size: 14pt;
font-size: 14pt; font-family: bitstream-vera, verdana, helvetica;
font-family: bitstream-vera, verdana, helvetica; color: #999;
color: #999; width: 130px;
width: 150px; height: 85px;
height: 85px; border-right: 1px solid #ccc;
border-right: 1px solid #ccc; border-bottom: 1px solid #ccc;
border-bottom: 1px solid #ccc; border-top: 1px solid #999;
border-top: 1px solid #999; border-left: 1px solid #999;
border-left: 1px solid #999; }
}
#time h1{ #time h1{
font-size: 18pt; font-size: 18pt;
@ -833,63 +832,65 @@ table.masterpalette td{
} }
#nowplaying { #nowplaying {
padding-top: 5px; padding-top: 5px;
background: #EBF1F8; background: #EBF1F8;
padding-bottom: 10px; padding-bottom: 10px;
padding-left: 10px; padding-left: 10px;
padding-right: 5px; padding-right: 5px;
font-family: bitstream-vera, verdana, helvetica; font-family: bitstream-vera, verdana, helvetica;
font: #999; font: #999;
width: 300px; width: 350px;
height: 85px; height: 85px;
border-right: 1px solid #ccc; border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
border-top: 1px solid #999; border-top: 1px solid #999;
border-left: 1px solid #999; border-left: 1px solid #999;
color: #999; color: #999;
} }
#nowplaying_indicator { #nowplaying_indicator {
padding-top: 5px; padding-top: 5px;
background: #EBF1F8; background: #EBF1F8;
padding-bottom: 10px; padding-bottom: 10px;
padding-left: 5px; padding-left: 5px;
padding-right: 5px; padding-right: 5px;
font-family: bitstream-vera, verdana, helvetica; font-family: bitstream-vera, verdana, helvetica;
font: #999; font: #999;
width: 150px; width: 130px;
height: 85px; height: 85px;
border-right: 1px solid #ccc; border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
border-top: 1px solid #999; border-top: 1px solid #999;
border-left: 1px solid #999; border-left: 1px solid #999;
text-align: center; text-align: center;
} }
#onair { #onair {
margin-top: 10px; margin-top: 10px;
font-size: 14pt; font-size: 14pt;
font-weight: bold; font-weight: bold;
color: #A2C6D6; color: #A2C6D6;
text-transform: uppercase; text-transform: uppercase;
} display: none;
}
#offair { #offair {
margin-top: 30px; margin-top: 30px;
font-size: 14pt; font-size: 14pt;
font-weight: bold; font-weight: bold;
color: #999; color: #999;
text-transform: uppercase; text-transform: uppercase;
} display: none;
}
#station { #station {
padding-top: 5px; padding-top: 5px;
padding-bottom: 5px; padding-bottom: 5px;
padding-left: 80px; padding-left: 80px;
padding-right: 5px; padding-right: 5px;
} }
/* *************** NOW/NEXT CLIP ****************** */ /* *************** NOW/NEXT CLIP ****************** */
@ -899,7 +900,7 @@ table.masterpalette td{
} }
.whatplaying .scala { .whatplaying .scala {
width: 290px; width: 340px;
height: 8px; height: 8px;
margin: 2px 0; margin: 2px 0;
background-color: #DADADA; background-color: #DADADA;
@ -926,7 +927,7 @@ table.masterpalette td{
} }
.whatplaying .left .left_title { .whatplaying .left .left_title {
width: 65px; width: 65px;
float: left; float: left;
display: block; display: block;
overflow: hidden; overflow: hidden;
margin-right: 3px; margin-right: 3px;
@ -950,14 +951,19 @@ table.masterpalette td{
width: 225px; width: 225px;
} }
.whatplaying #next_clip { .whatplaying #next_clip,
.whatplaying #upcoming_playlist,
.whatplaying #upcoming_clip {
clear: both; clear: both;
display: block; display: block;
font-size: 11px; font-size: 11px;
height: 1.4em; height: 1.4em;
overflow: hidden; overflow: hidden;
} }
.whatplaying #next_clip .next {
.whatplaying #next_clip .next,
.whatplaying #upcoming_playlist .next,
.whatplaying #upcoming_clip .next {
width: 65px; width: 65px;
float: left; float: left;
display: block; display: block;
@ -966,21 +972,34 @@ table.masterpalette td{
} }
.loginname { .loginname {
font-size: 12px; font-size: 12px;
font-weight: bold; font-weight: bold;
float : right; float : right;
} }
.station { font-size: 12px; .station {
font-size: 12px;
margin: 30px 30px 0 30px; margin: 30px 30px 0 30px;
float: left; float: left;
} }
.frequence { font-size: 12px; .frequence {
font-size: 12px;
margin: 15px 0 8px 0; margin: 15px 0 8px 0;
} }
/* micz */ /* micz */
.whatplaying .title { .whatplaying .title {
max-height: 3em; max-height: 3em;
overflow: hidden; overflow: hidden;
}
#now_title_,
#now_scala_,
#now_elapsed_,
#now_remaining_,
#now_pltitle_,
#next_title_,
#upcoming_pltitle_,
#upcoming_title_ {
visibility: hidden;
} }

View File

@ -7,7 +7,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
{* <link rel="stylesheet" href="styles.css"> *} {* <link rel="stylesheet" href="styles.css"> *}
<link href="styles_livesupport.css" rel="stylesheet" type="text/css" /> <link href="styles_campcaster.css" rel="stylesheet" type="text/css" />
{include file="script/basics.js.tpl"} {include file="script/basics.js.tpl"}
{include file="script/contextmenu.js.tpl"} {include file="script/contextmenu.js.tpl"}

View File

@ -3,121 +3,210 @@
{literal} {literal}
// play-progress-bar object // play-progress-bar object
function plPrBar(tit, eh, ei, es, dh, di, ds, next, ntit, nh, ni, ns, pltit){ function plPrBar() {
this.tit = tit; this.debug = true;
this.pltit = pltit; plPrBar_debug('new plPrBar');
this.next = next;
this.interval = 333;
this.ntit = ntit.slice(0, 22);
this.nh = nh;
this.ni = ni;
this.ns = ns;
// inits:
this.elapsed = new Date();
this.duration = new Date();
this.remaining = new Date();
this.elapsed.setTime (Date.UTC(1970, 0, 1, eh, ei, es));
this.duration.setTime(Date.UTC(1970, 0, 1, dh, di, ds));
// methods: // methods:
this.init = plPrBar_init; this.init = plPrBar_init;
this.tick = plPrBar_tick; this.tick = plPrBar_tick;
this.update = plPrBar_update; this.update = plPrBar_update;
this.stop = plPrBar_stop; this.onair = plPrBar_onair;
this.show = plPrBar_show; this.offair = plPrBar_offair;
this.hide = plPrBar_hide; this.show = plPrBar_show;
this.create = plPrBar_create; this.hide = plPrBar_hide;
this.run = setInterval("ppb.tick();", this.interval); this.create = plPrBar_create;
this.request = plPrBar_request;
} }
function plPrBar_init() {
document.getElementById("now_title").innerHTML = this.tit;
document.getElementById("now_pl_title").innerHTML = this.pltit;
if (this.next == 0) { function plPrBar_init(current, c_tit, c_pltit, c_eh, c_ei, c_es, c_dh, c_di, c_ds,
document.getElementById("next_clip").innerHTML = ''; next, n_tit, n_pltit, n_dh, n_di, n_ds,
} else { upcoming, u_tit, u_pltit, u_dh, u_di, u_ds, u_sh, u_si, u_ss) {
document.getElementById("next_title").innerHTML = this.ntit; plPrBar_debug('init');
document.getElementById("next_duration").innerHTML = '(' + twoDigit(this.nh) + ':' + twoDigit(this.ni) + ':' + twoDigit(this.ns) + ')'; this.interval = 333;
if (current == 1) {
//plPrBar_debug('init::current: ' + current);
this.current = true;
this.c_tit = c_tit;
this.c_pltit = c_pltit;
this.c_elapsed = new Date();
this.c_duration = new Date();
this.c_remaining = new Date();
this.c_elapsed.setTime (Date.UTC(1970, 0, 1, c_eh, c_ei, c_es));
this.c_duration.setTime(Date.UTC(1970, 0, 1, c_dh, c_di, c_ds));
this.c_remaining.setTime(this.c_duration.getTime() - this.c_elapsed.getTime());
}
if (next == 1) {
//plPrBar_debug('init::next: ' + next);
this.next = true;
this.n_tit = n_tit.slice(0, 22);
this.n_pltit = n_pltit.slice(0, 22);
this.n_duration = new Date;
this.n_duration.setTime(Date.UTC(1970, 0, 1, n_dh, n_di, n_ds));
}
if (upcoming == 1) {
//plPrBar_debug('init::upcoming: ' + upcoming);
this.upcoming = true;
this.u_tit = u_tit;
this.u_pltit = u_pltit;
this.u_duration = new Date;
this.u_duration.setTime(Date.UTC(1970, 0, 1, u_dh, u_di, u_ds));
this.u_plstart = new Date();
this.u_plstart.setTime(Date.UTC(1970, 0, 1, u_sh, u_si, u_ss));
}
if (this.current) {
this.show('now');
document.getElementById("now_title").innerHTML = this.c_tit;
document.getElementById("now_pltitle").innerHTML = this.c_pltit;
this.progress = window.setInterval("ppb.tick();", this.interval);
this.onair();
this.update();
} else {
this.hide('now');
this.offair();
}
if (this.next) {
this.show('next');
document.getElementById("next_title").innerHTML = this.n_tit;
document.getElementById("next_duration").innerHTML = '(' + twoDigit(this.n_duration.getUTCHours())
+ ':' + twoDigit(this.n_duration.getUTCMinutes())
+ ':' + twoDigit(this.n_duration.getUTCSeconds()) + ')';
} else {
this.hide('next');
}
if (this.upcoming) {
this.show('upcoming');
document.getElementById("upcoming_pltitle").innerHTML = this.u_pltit;
document.getElementById("upcoming_plstart").innerHTML = '(at ' + twoDigit(this.u_plstart.getUTCHours())
+ ':' + twoDigit(this.u_plstart.getUTCMinutes())
+ ':' + twoDigit(this.u_plstart.getUTCSeconds()) + ')';
document.getElementById("upcoming_title").innerHTML = this.u_tit;
document.getElementById("upcoming_duration").innerHTML = '(' + twoDigit(this.u_duration.getUTCHours())
+ ':' + twoDigit(this.u_duration.getUTCMinutes())
+ ':' + twoDigit(this.u_duration.getUTCSeconds()) + ')';
} else {
this.hide('upcoming');
} }
this.show();
this.update();
} }
function plPrBar_tick() { function plPrBar_tick() {
if (this.remaining.getTime() <= this.interval*2) { //plPrBar_debug('tick:' + this.c_remaining.getTime());
this.stop(); if (this.c_remaining.getTime() <= this.interval*2) {
window.clearInterval(progress);
return; return;
} }
this.c_elapsed.setTime(this.c_elapsed.getTime() + this.interval);
this.elapsed.setTime(this.elapsed.getTime() + this.interval); this.c_remaining.setTime(this.c_duration.getTime() - this.c_elapsed.getTime());
this.remaining.setTime(this.duration.getTime() - this.elapsed.getTime());
this.update(); this.update();
} }
function plPrBar_update() { function plPrBar_update() {
document.getElementById("now_elapsed").innerHTML = twoDigit(this.elapsed.getUTCHours()) + ":" + twoDigit(this.elapsed.getUTCMinutes()) + ":" + twoDigit(this.elapsed.getUTCSeconds()); //plPrBar_debug('update');
document.getElementById("now_remaining").innerHTML = twoDigit(this.remaining.getUTCHours()) + ":" + twoDigit(this.remaining.getUTCMinutes()) + ":" + twoDigit(this.remaining.getUTCSeconds()); document.getElementById("now_elapsed").innerHTML = twoDigit(this.c_elapsed.getUTCHours()) + ":" + twoDigit(this.c_elapsed.getUTCMinutes()) + ":" + twoDigit(this.c_elapsed.getUTCSeconds());
document.getElementById("now_scala").style.width = (100 / this.duration.getTime() * this.elapsed.getTime()) + "%"; document.getElementById("now_remaining").innerHTML = twoDigit(this.c_remaining.getUTCHours()) + ":" + twoDigit(this.c_remaining.getUTCMinutes()) + ":" + twoDigit(this.c_remaining.getUTCSeconds());
document.getElementById("now_scala").style.width = (100 / this.c_duration.getTime() * this.c_elapsed.getTime()) + "%";
} }
function plPrBar_stop() { function plPrBar_request() {
clearInterval(this.run); plPrBar_debug('request');
jsCom("jscom_wrapper", ["uiBrowser", "SCHEDULER", "getScheduleInfo_jscom", "1"], this.create);
if (this.next == 0) {
// just if no next item to play
this.hide();
} else {
// all values for next clip needed here:
jsCom("jscom_wrapper", ["uiBrowser", "SCHEDULER", "getNowNextClip4jscom"], this.create);
}
} }
function plPrBar_create(jscomRes) { function plPrBar_create(jscomRes) {
if (jscomRes !== '') { plPrBar_debug('create: ' + jscomRes);
eval('var parms = ' + jscomRes + ';'); window.clearInterval(ppb.progress);
ppb = new plPrBar(parms[0], if (jscomRes !== '') {
parms[1], parms[2], parms[3], eval('var parms = ' + jscomRes + ';');
parms[4], parms[5], parms[6], ppb = new plPrBar();
parms[7], parms[8], parms[9], parms[10], parms[11], ppb.init(parms[0], parms[1], parms[2], parms[3], parms[4], parms[5], parms[6], parms[7], parms[8],
parms[12] parms[9], parms[10], parms[11], parms[12], parms[13], parms[14],
); parms[15], parms[16], parms[17], parms[18], parms[19], parms[20], parms[21], parms[22], parms[23]);
ppb.init(); } else {
} else { plPrBar_hide('now');
plPrBar_hide(); plPrBar_hide('next');
}; plPrBar_hide('upcoming');
};
setTimeout("ppb.request()", 10000);
} }
function plPrBar_show() { function plPrBar_onair() {
document.getElementById("nowplaying_indicator").innerHTML = '<div id="onair">##Playing Scheduled Item##</div>'; plPrBar_debug('onair');
document.getElementById("offair").style.display = 'none';
document.getElementById("onair").style.display = 'block';
} }
function plPrBar_hide() { function plPrBar_offair() {
document.getElementById("nowplaying_indicator").innerHTML = '<div id="offair">##Off Air##</div>'; plPrBar_debug('offair');
document.getElementById("nowplaying").innerHTML = ""; document.getElementById("onair").style.display = 'none';
document.getElementById("offair").style.display = 'block';
}
function plPrBar_show(what) {
plPrBar_debug('show: ' + what);
if (what == 'now') {
document.getElementById("now_title_").style.visibility = 'visible';
document.getElementById("now_pltitle_").style.visibility = 'visible';
document.getElementById("now_elapsed_").style.visibility = 'visible';
document.getElementById("now_remaining_").style.visibility = 'visible';
document.getElementById("now_scala_").style.visibility = 'visible';
}
if (what == 'next') {
document.getElementById("next_title_").style.visibility = 'visible';
}
if (what == 'upcoming') {
document.getElementById("upcoming_pltitle_").style.visibility = 'visible';
document.getElementById("upcoming_title_").style.visibility = 'visible';
}
}
function plPrBar_hide(what) {
plPrBar_debug('hide: ' + what);
if (what == 'now') {
document.getElementById("now_title_").style.visibility = 'hidden';
document.getElementById("now_title").innerHTML = '';
document.getElementById("now_pltitle_").style.visibility = 'hidden';
document.getElementById("now_pltitle").innerHTML = '';
document.getElementById("now_elapsed_").style.visibility = 'hidden';
document.getElementById("now_elapsed").innerHTML = '';
document.getElementById("now_remaining_").style.visibility = 'hidden';
document.getElementById("now_remaining").innerHTML = '';
document.getElementById("now_scala_").style.visibility = 'hidden';
}
if (what == 'next') {
document.getElementById("next_title_").style.visibility = 'hidden';
document.getElementById("next_title").innerHTML = '';
document.getElementById("next_duration").innerHTML = '';
}
if (what == 'upcoming') {
document.getElementById("upcoming_pltitle_").style.visibility = 'hidden';
document.getElementById("upcoming_pltitle").innerHTML = '';
document.getElementById("upcoming_title_").style.visibility = 'hidden';
document.getElementById("upcoming_title").innerHTML = '';
}
}
function plPrBar_debug(msg) {
if (ppb_debug) {
var jetzt = new Date();
var Min = jetzt.getMinutes();
var Sek = jetzt.getSeconds();
var Min = ((Min < 10) ? "0" + Min : Min);
var Sek = ((Sek < 10) ? "0" + Sek : Sek);
var Stamp = Min+':'+Sek;
document.getElementById('debug_console').innerHTML = document.getElementById('debug_console').innerHTML + Stamp + ' ' + msg + '<br>';
}
} }
{/literal} {/literal}
{if (is_array($_nowplaying.duration))}
ppb = new plPrBar ("{$_nowplaying.title|escape:html}",
{$_nowplaying.elapsed.h|string_format:"%d"}, {$_nowplaying.elapsed.m|string_format:"%d"}, {$_nowplaying.elapsed.s|string_format:"%d"},
{$_nowplaying.duration.h|string_format:"%d"}, {$_nowplaying.duration.m|string_format:"%d"}, {$_nowplaying.duration.s|string_format:"%d"},
{if is_array($_nextplaying)}
1, "{$_nextplaying.title|escape:html}", {$_nextplaying.duration.h|string_format:'%d'}, {$_nextplaying.duration.m|string_format:'%2d'}, {$_nextplaying.duration.s|string_format:'%2d'}
{else}
0, "", 0, 0, 0
{/if}
, "{$_nowplaying.playlist|escape:html}"
);
ppb.init();
{/if}
{$JSCOM->genJsCode()} {$JSCOM->genJsCode()}
ppb_debug = false;
ppb = new plPrBar();
ppb.request();
//interval = setInterval("ppb.request();", 10000);
</script> </script>

View File

@ -1,6 +1,3 @@
{assign var='_nowplaying' value=$SCHEDULER->getNowNextClip()}
{assign var='_nextplaying' value=$SCHEDULER->getNowNextClip(1)}
<div id="masterpalette"> <div id="masterpalette">
<table border="0" class="masterpalette"> <table border="0" class="masterpalette">
<tr> <tr>
@ -21,56 +18,63 @@
<td> <td>
<div id="nowplaying"> <div id="nowplaying">
<div class="whatplaying"> <div class="whatplaying">
{if $_nowplaying} <div class="title" id="now_title_">##Now Playing##: <span id="now_title"></span></div>
<div class="title">##Now Playing##: <span id="now_title"></span></div> <div class="scala" id="now_scala_">
<div class="scala"> <div class="scala_in" id="now_scala" style="width: 0%;">&nbsp;</div>
<div class="scala_in" id="now_scala" style="width: {$_nowplaying.percentage}%;">&nbsp;</div> </div>
</div>
<div class="time">
<span class="left">
<span class="left_title" id="now_elapsed_">##Elapsed:##</span>
<strong id="now_elapsed"></strong>
</span>
<div class="time"> <span class="right">
<span class="left"> <span id="now_remaining_">##Remaining:##</span>
<span class="left_title">##Elapsed:##</span> <strong id="now_remaining"></strong>
<strong id="now_elapsed"></strong> </span>
</span> </div>
<span class="right"> <div class="playlist">
##Remaining:## <span class="left">
<strong id="now_remaining"></strong> <span class="left_title" id="now_pltitle_">##Playlist:##</span>
</span> <span>
</div> <strong class="playlist_title" id="now_pltitle"></strong>
</div>
<div class="playlist">
<span class="left"> <div style="height:3px"> </div>
<span class="left_title">##Playlist:##</span>
<span>
<strong class="playlist_title" id="now_pl_title"></strong>
</div>
{/if}
<div style="height:3px"> </div>
<div id="next_clip"> <div id="next_clip">
{if $_nextplaying} <span class="next" id="next_title_">##Next File##:</span>
<span class="next">##Next Clip##:</span>
<strong id="next_title"></strong> <strong id="next_title"></strong>
&nbsp;<span id="next_duration"></span> &nbsp;<span id="next_duration"></span>
{/if} </div>
<div id="upcoming_playlist">
<span class="next" id="upcoming_pltitle_">##Upcoming Playlist##:</span>
<strong id="upcoming_pltitle"></strong>
&nbsp;<span id="upcoming_plstart"></span>
</div>
<div id="upcoming_clip">
<span class="next" id="upcoming_title_">##Upcoming Title##:</span>
<strong id="upcoming_title"></strong>
&nbsp;<span id="upcoming_duration"></span>
</div> </div>
</div> </div>
</div> </div>
</td> </td>
<td> <td>
{if $_nowplaying} <div id="nowplaying_indicator">
<div id="nowplaying_indicator"><div id="onair">##Playing Scheduled Item##</div></div> <div id="onair">##Playing Scheduled Item##</div>
{else} <div id="offair">##Off Air##</div>
<div id="nowplaying_indicator"><div id="offair">##Off Air##</div></div> </div>
{/if}
</td> </td>
<td> <td>
<div id="station"> <div id="debug_console" style="width: 180px; height: 140px; overflow: auto">
<img src="{$STATIONPREFS.stationLogoPath}" alt="{$STATIONPREFS.stationName}">
</div> </div>
</td> </td>
</tr> </tr>
@ -79,8 +83,4 @@
{include file="script/clock.js.tpl"} {include file="script/clock.js.tpl"}
{include file="script/progressbar.js.tpl"} {include file="script/progressbar.js.tpl"}
{assign var='_nowplaying' value=null}
{assign var='_nextplaying' value=null}

View File

@ -142,7 +142,7 @@ class uiScheduler extends uiCalendar {
$this->curr['hour'] = sprintf('%02d', $hour); $this->curr['hour'] = sprintf('%02d', $hour);
} }
$stampNow = uiScheduler::datetimeToTimestamp($this->curr['year'] $stampNow = self::datetimeToTimestamp($this->curr['year']
.$this->curr['month'] .$this->curr['month']
.$this->curr['day'] .$this->curr['day']
.'T'.$this->curr['hour'].':00:00'); .'T'.$this->curr['hour'].':00:00');
@ -246,7 +246,7 @@ class uiScheduler extends uiCalendar {
$this->scheduleNext['minute'] = 59; $this->scheduleNext['minute'] = 59;
$this->scheduleNext['second'] = 59; $this->scheduleNext['second'] = 59;
$this->scheduleAtTime['stamp'] = uiScheduler::datetimeToTimestamp( $this->scheduleAtTime['stamp'] = self::datetimeToTimestamp(
$this->scheduleAtTime['year'] $this->scheduleAtTime['year']
.$this->scheduleAtTime['month'] .$this->scheduleAtTime['month']
.$this->scheduleAtTime['day'] .$this->scheduleAtTime['day']
@ -311,15 +311,15 @@ class uiScheduler extends uiCalendar {
$items = array(); $items = array();
foreach ($arr as $key => $val) { foreach ($arr as $key => $val) {
$id = BasicStor::IdFromGunid($val['playlistId']); $id = BasicStor::IdFromGunid($val['playlistId']);
$startDay = strftime('%d', uiScheduler::datetimeToTimestamp($val['start'])); $startDay = strftime('%d', self::datetimeToTimestamp($val['start']));
$startHour = number_format(strftime('%H', uiScheduler::datetimeToTimestamp($val['start']))); $startHour = number_format(strftime('%H', self::datetimeToTimestamp($val['start'])));
$items[$startDay][$startHour][]= array ( $items[$startDay][$startHour][]= array (
'id' => $id, 'id' => $id,
'scheduleid'=> $val['id'], 'scheduleid'=> $val['id'],
'start' => substr($val['start'], strpos($val['start'], 'T')+1), 'start' => substr($val['start'], strpos($val['start'], 'T')+1),
'end' => substr($val['end'], strpos($val['end'], 'T')+1), 'end' => substr($val['end'], strpos($val['end'], 'T')+1),
'start_stamp' => uiScheduler::datetimeToTimestamp($val['start']), 'start_stamp' => self::datetimeToTimestamp($val['start']),
'end_stamp' => uiScheduler::datetimeToTimestamp($val['end']), 'end_stamp' => self::datetimeToTimestamp($val['end']),
'title' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE), 'title' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE),
'creator' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_CREATOR), 'creator' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_CREATOR),
'type' => 'Playlist' 'type' => 'Playlist'
@ -348,8 +348,8 @@ class uiScheduler extends uiCalendar {
$items = array(); $items = array();
foreach ($arr as $key => $val) { foreach ($arr as $key => $val) {
$start = uiScheduler::datetimeToTimestamp($val['start']); $start = self::datetimeToTimestamp($val['start']);
$end = uiScheduler::datetimeToTimestamp($val['end']); $end = self::datetimeToTimestamp($val['end']);
$Y = strftime('%Y', $start); $Y = strftime('%Y', $start);
$m = number_format(strftime('%m', $start)); $m = number_format(strftime('%m', $start));
$d = number_format(strftime('%d', $start)); $d = number_format(strftime('%d', $start));
@ -447,7 +447,7 @@ class uiScheduler extends uiCalendar {
if (!count($arr)) if (!count($arr))
return FALSE; return FALSE;
foreach ($arr as $key => $val) { foreach ($arr as $key => $val) {
$items[date('H', uiScheduler::datetimeToTimestamp($val['start']))][]= array ( $items[date('H', self::datetimeToTimestamp($val['start']))][]= array (
'start' => substr($val['start'], strpos($val['start'], 'T')+1), 'start' => substr($val['start'], strpos($val['start'], 'T')+1),
'end' => substr($val['end'], strpos($val['end'], 'T') + 1), 'end' => substr($val['end'], strpos($val['end'], 'T') + 1),
'title' => $this->Base->getMetadataValue(BasicStor::IdFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE), 'title' => $this->Base->getMetadataValue(BasicStor::IdFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE),
@ -473,8 +473,8 @@ class uiScheduler extends uiCalendar {
$id = BasicStor::IdFromGunid($val['playlistId']); $id = BasicStor::IdFromGunid($val['playlistId']);
$arr[$key]['title'] = $this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE); $arr[$key]['title'] = $this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE);
$arr[$key]['creator'] = $this->Base->getMetadataValue($id, UI_MDATA_KEY_CREATOR); $arr[$key]['creator'] = $this->Base->getMetadataValue($id, UI_MDATA_KEY_CREATOR);
$arr[$key]['pos'] = uiScheduler::datetimeToTimestamp($val['start']); $arr[$key]['pos'] = self::datetimeToTimestamp($val['start']);
$arr[$key]['span'] = date('H', uiScheduler::datetimeToTimestamp($val['end'])) - date('H', uiScheduler::datetimeToTimestamp($val['start'])) +1; $arr[$key]['span'] = date('H', self::datetimeToTimestamp($val['end'])) - date('H', self::datetimeToTimestamp($val['start'])) +1;
} }
return $arr; return $arr;
} // fn getDayUsage } // fn getDayUsage
@ -496,7 +496,7 @@ class uiScheduler extends uiCalendar {
$duration = 0; $duration = 0;
foreach ($arr as $val) { foreach ($arr as $val) {
$duration += (uiScheduler::datetimeToTimestamp($val['end'])-uiScheduler::datetimeToTimestamp($val['start']))/86400*100; $duration += (self::datetimeToTimestamp($val['end'])-self::datetimeToTimestamp($val['start']))/86400*100;
} }
return $duration; return $duration;
} // fn getDayUsagePercentage } // fn getDayUsagePercentage
@ -586,29 +586,54 @@ class uiScheduler extends uiCalendar {
/** /**
* Get the currently playing clip or one that is coming up. * Get an scheduled playlist
* *
* Note: just use methods here which work without valid authentification. * Note: just use methods here which work without valid authentification.
* *
* @param int $distance * @param int $p_playlist_nr
* 0=current clip; 1=next clip ... * 0=current pl; 1=next pl ...
* @return array * @return array
*/ */
public function getNowNextClip($distance=0) public function getScheduledPlaylist($p_playlist_nr=0, $p_period=3600)
{ {
$datetime = strftime('%Y-%m-%dT%H:%M:%S'); $now = time();
$xmldatetime = str_replace('-', '', $datetime); $start = strftime('%Y%m%dT%H:%M:%S', $now);
$pl = $this->displayScheduleMethod($xmldatetime, $xmldatetime); $end = $p_playlist_nr ? strftime('%Y%m%dT%H:%M:%S', $now + $p_period) : strftime('%Y%m%dT%H:%M:%S', $now);
$playlists = $this->displayScheduleMethod($start, $end);
if (!is_array($pl) || !count($pl)) { if (!is_array($playlists) || !count($playlists)) {
return FALSE; return FALSE;
} }
$pl = current($pl); switch ($p_playlist_nr) {
case 0:
if ($playlist = current($playlists)) {
return $playlist;
}
break;
default:
$pos = 0;
foreach ($playlists as $playlist) {
if (self::datetimeToTimestamp($playlist['start']) > $now) {
$pos++;
if ($pos == $p_playlist_nr) {
return $playlist;
}
}
}
break;
}
return false;
} // fn getScheduledPlaylist
public function getClipFromCurrent($p_playlist, $p_item_nr=0)
{
// subtract difference to UTC // subtract difference to UTC
$offset = strftime('%H:%M:%S', time() - uiScheduler::datetimeToTimestamp($pl['start']) - 3600 * strftime('%H', 0)); $offset = strftime('%H:%M:%S', time() - self::datetimeToTimestamp($p_playlist['start']) - 3600 * strftime('%H', 0));
$clip = $this->Base->gb->displayPlaylistClipAtOffset($this->Base->sessid, $pl['playlistId'], $offset, $distance, $_SESSION['langid'], UI_DEFAULT_LANGID); $clip = $this->Base->gb->displayPlaylistClipAtOffset($this->Base->sessid, $p_playlist['playlistId'], $offset, $p_item_nr, $_SESSION['langid'], UI_DEFAULT_LANGID);
if (!$clip['gunid']) { if (!$clip['gunid']) {
return FALSE; return FALSE;
@ -631,34 +656,84 @@ class uiScheduler extends uiCalendar {
'percentage'=> $percentage, 'percentage'=> $percentage,
'playlist' => $clip['playlist'] 'playlist' => $clip['playlist']
); );
} // fn getNowNextClip }
public function getClipFromPlaylist($p_playlist, $p_position=0)
{
$pos = 0;
$playlist = new uiPlaylist($this->Base);
$flat = $playlist->getFlat(BasicStor::IdFromGunid($p_playlist['playlistId']));
foreach ($flat as $clip) {
if ($pos == $p_position) {
$found = true;
break;
}
$pos++;
}
if ($found) {
list($duration['h'], $duration['m'], $duration['s']) = explode(':', $clip['attrs']['clipLength']);
list($elapsed['h'], $elapsed['m'], $elapsed['s']) = explode(':', '00:00:00');
$remaining = $duration;
$duration = array_map('round', $duration);
$elapsed = array_map('round', $elapsed);
$remaining = array_map('round', $remaining);
$percentage = $secondsElapsed ? (100 * $secondsElapsed / ($secondsElapsed + $secondsRemaining)) : 100;
return array(
'title' => $clip['title'],
'duration' => $duration,
'elapsed' => $elapsed,
'remaining' => $remaining,
'percentage'=> $percentage
);
}
return false;
}
public function getNowNextClip4jscom() public function getScheduleInfo_jscom($p_playlist_nr=0)
{ {
// just use methods which work without valid authentification // just use methods which work without valid authentification
if ($curr = $this->getNowNextClip()) { $c_pl = self::getScheduledPlaylist();
$next = $this->getNowNextClip(1); if ($c_clip = $this->getClipFromCurrent($c_pl, 0)) {
return array( $n_clip = $this->getClipFromCurrent($c_pl, 1);
'title' => $curr['title'],
'elapsed.h' => $curr['elapsed']['h'],
'elapsed.m' => $curr['elapsed']['m'],
'elapsed.s' => $curr['elapsed']['s'],
'duration.h' => $curr['duration']['h'],
'duration.m' => $curr['duration']['m'],
'duration.s' => $curr['duration']['s'],
'next' => $next ? 1 : 0,
'next.title' => $next ? $next['title'] : "",
'next.dur.h' => $next ? $next['duration']['h'] : 0,
'next.dur.m' => $next ? $next['duration']['m'] : 0,
'next.dur.s' => $next ? $next['duration']['s'] : 0,
'playlist' => $curr['playlist'],
);
} else {
return FALSE;
} }
} // fn getNowNextClip4jscom if ($u_pl = self::getScheduledPlaylist(1)) {
$u_clip = $this->getClipFromPlaylist($u_pl);
$u_pl_start = explode(':', date('H:i:s', self::datetimeToTimestamp($u_pl['start'])));
}
return array(
'current' => $c_clip ? 1 : 0,
'current.title' => addcslashes($c_clip['title'], "'"),
'current.pltitle' => addcslashes($this->Base->getMetadataValue(BasicStor::IdFromGunid($c_pl['playlistId']), UI_MDATA_KEY_TITLE), "'"),
'current.elapsed.h' => $c_clip['elapsed']['h'],
'current.elapsed.m' => $c_clip['elapsed']['m'],
'current.elapsed.s' => $c_clip['elapsed']['s'],
'current.duration.h' => $c_clip['duration']['h'],
'current.duration.m' => $c_clip['duration']['m'],
'current.duration.s' => $c_clip['duration']['s'],
'next' => $n_clip ? 1 : 0,
'next.title' => $n_clip ? addcslashes($n_clip['title'], "'") : "",
'next.pltitle' => addcslashes($this->Base->getMetadataValue(BasicStor::IdFromGunid($n_pl['playlistId']), UI_MDATA_KEY_TITLE), "'"),
'next.duration.h' => $n_clip ? $n_clip['duration']['h'] : 0,
'next.duration.m' => $n_clip ? $n_clip['duration']['m'] : 0,
'next.duration.s' => $n_clip ? $n_clip['duration']['s'] : 0,
'upcoming' => $u_pl ? 1 : 0,
'upcoming.title' => addcslashes($u_clip['title'], "'"),
'upcoming.pltitle' => addcslashes($this->Base->getMetadataValue(BasicStor::IdFromGunid($u_pl['playlistId']), UI_MDATA_KEY_TITLE), "'"),
'upcoming.duration.h' => $u_clip['duration']['h'],
'upcoming.duration.m' => $u_clip['duration']['m'],
'upcoming.duration.s' => $u_clip['duration']['s'],
'upcoming.plstart.h' => $u_pl_start[0],
'upcoming.plstart.m' => $u_pl_start[1],
'upcoming.plstart.s' => $u_pl_start[2],
);
} // fn getNowPlaying4jscom
/** /**
@ -671,7 +746,7 @@ class uiScheduler extends uiCalendar {
{ {
$i = str_replace('T', ' ', $i); $i = str_replace('T', ' ', $i);
$formatted = $i[0].$i[1].$i[2].$i[3].'-'.$i[4].$i[5].'-'.$i[6].$i[7].strrchr($i, ' '); $formatted = $i[0].$i[1].$i[2].$i[3].'-'.$i[4].$i[5].'-'.$i[6].$i[7].strrchr($i, ' ');
return uiScheduler::strtotime($formatted); return self::strtotime($formatted);
} // fn datetimeToTimestamp } // fn datetimeToTimestamp
@ -738,11 +813,11 @@ class uiScheduler extends uiCalendar {
$pStampArr = null; $pStampArr = null;
foreach ($pArr as $val) { foreach ($pArr as $val) {
$pStampArr[] = array('start' => uiScheduler::datetimeToTimestamp($val['start']), $pStampArr[] = array('start' => self::datetimeToTimestamp($val['start']),
'end' => uiScheduler::datetimeToTimestamp($val['end'])); 'end' => self::datetimeToTimestamp($val['end']));
} }
if (is_array($pStampArr)) { if (is_array($pStampArr)) {
for ($n = uiScheduler::datetimeToTimestamp($dfrom); $n <= uiScheduler::datetimeToTimestamp($dto); $n+=86400) { for ($n = self::datetimeToTimestamp($dfrom); $n <= self::datetimeToTimestamp($dto); $n+=86400) {
foreach ($pStampArr as $val) { foreach ($pStampArr as $val) {
if ($val['start'] < $n+86400 && $val['end'] >= $n) { if ($val['start'] < $n+86400 && $val['end'] >= $n) {
$days[date('Ymd', $n)] = array('year' => date('Y', $n), $days[date('Ymd', $n)] = array('year' => date('Y', $n),

View File

@ -658,8 +658,16 @@ class Playlist extends StoredFile {
$dd = 0; $dd = 0;
$found = FALSE; $found = FALSE;
foreach ($plArr['els'] as $el) { foreach ($plArr['els'] as $el) {
extract($el); // acLen, elOffset, acGunid, fadeIn, fadeOut, playlist extract($el); // acGunid, acLen, acLenS, clipEnd, clipEndS, clipStart, clipStartS,
if ( ($offsetS >= $elOffsetS) && ($offsetS < ($elOffsetS + $acLenS)) ) { // elOffset, elOffsetS, fadeIn, fadeInS, fadeOut, fadeOutS, type
$lengthS = $acLenS;
if ($clipEndS) {
$lengthS = $clipEndS;
}
if ($clipStartS) {
$lengthS = $lengthS - $clipStartS;
}
if ( ($offsetS >= $elOffsetS) && ($offsetS < ($elOffsetS + $lengthS)) ) {
$found = TRUE; $found = TRUE;
} }
if ($found) { // we've found offset if ($found) { // we've found offset
@ -690,11 +698,11 @@ class Playlist extends StoredFile {
if ($playedS < 0) { if ($playedS < 0) {
$playedS = 0; $playedS = 0;
} }
$remainS = $acLenS - $playedS; $remainS = $lengthS - $playedS;
$res = array('gunid'=>$acGunid, $res = array('gunid'=>$acGunid,
'elapsed' => Playlist::secondsToPlaylistTime($playedS), 'elapsed' => Playlist::secondsToPlaylistTime($playedS),
'remaining' => Playlist::secondsToPlaylistTime($remainS), 'remaining' => Playlist::secondsToPlaylistTime($remainS),
'duration' => Playlist::secondsToPlaylistTime($acLenS), 'duration' => Playlist::secondsToPlaylistTime($lengthS),
); );
return $res; return $res;
} }
@ -1360,6 +1368,10 @@ class PlaylistElement {
'fadeInS' => 0, 'fadeInS' => 0,
'fadeOut' => '00:00:00.000000', 'fadeOut' => '00:00:00.000000',
'fadeOutS' => 0, 'fadeOutS' => 0,
'clipStart' => '00:00:00.000000',
'clipStartS' => 0,
'clipEnd' => '00:00:00.000000',
'clipEndS' => 0
); );
$plInfo['elOffset'] = $this->plEl['attrs']['relativeOffset']; $plInfo['elOffset'] = $this->plEl['attrs']['relativeOffset'];
$plInfo['elOffsetS'] = Playlist::playlistTimeToSeconds($plInfo['elOffset']); $plInfo['elOffsetS'] = Playlist::playlistTimeToSeconds($plInfo['elOffset']);
@ -1387,6 +1399,10 @@ class PlaylistElement {
$plInfo['fadeOutS'] = Playlist::playlistTimeToSeconds($plInfo['fadeOut']); $plInfo['fadeOutS'] = Playlist::playlistTimeToSeconds($plInfo['fadeOut']);
break; break;
} }
$plInfo['clipStart'] = $this->plEl['attrs']['clipStart'];
$plInfo['clipStartS'] = Playlist::playlistTimeToSeconds($this->plEl['attrs']['clipStart']);
$plInfo['clipEnd'] = $this->plEl['attrs']['clipEnd'];
$plInfo['clipEndS'] = Playlist::playlistTimeToSeconds($this->plEl['attrs']['clipEnd']);
} }
return $plInfo; return $plInfo;
} }