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

View File

@ -3,121 +3,210 @@
{literal}
// play-progress-bar object
function plPrBar(tit, eh, ei, es, dh, di, ds, next, ntit, nh, ni, ns, pltit){
this.tit = tit;
this.pltit = pltit;
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));
function plPrBar() {
this.debug = true;
plPrBar_debug('new plPrBar');
// methods:
this.init = plPrBar_init;
this.tick = plPrBar_tick;
this.update = plPrBar_update;
this.stop = plPrBar_stop;
this.show = plPrBar_show;
this.hide = plPrBar_hide;
this.create = plPrBar_create;
this.run = setInterval("ppb.tick();", this.interval);
this.init = plPrBar_init;
this.tick = plPrBar_tick;
this.update = plPrBar_update;
this.onair = plPrBar_onair;
this.offair = plPrBar_offair;
this.show = plPrBar_show;
this.hide = plPrBar_hide;
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) {
document.getElementById("next_clip").innerHTML = '';
} else {
document.getElementById("next_title").innerHTML = this.ntit;
document.getElementById("next_duration").innerHTML = '(' + twoDigit(this.nh) + ':' + twoDigit(this.ni) + ':' + twoDigit(this.ns) + ')';
function plPrBar_init(current, c_tit, c_pltit, c_eh, c_ei, c_es, c_dh, c_di, c_ds,
next, n_tit, n_pltit, n_dh, n_di, n_ds,
upcoming, u_tit, u_pltit, u_dh, u_di, u_ds, u_sh, u_si, u_ss) {
plPrBar_debug('init');
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() {
if (this.remaining.getTime() <= this.interval*2) {
this.stop();
//plPrBar_debug('tick:' + this.c_remaining.getTime());
if (this.c_remaining.getTime() <= this.interval*2) {
window.clearInterval(progress);
return;
}
this.elapsed.setTime(this.elapsed.getTime() + this.interval);
this.remaining.setTime(this.duration.getTime() - this.elapsed.getTime());
this.c_elapsed.setTime(this.c_elapsed.getTime() + this.interval);
this.c_remaining.setTime(this.c_duration.getTime() - this.c_elapsed.getTime());
this.update();
}
function plPrBar_update() {
document.getElementById("now_elapsed").innerHTML = twoDigit(this.elapsed.getUTCHours()) + ":" + twoDigit(this.elapsed.getUTCMinutes()) + ":" + twoDigit(this.elapsed.getUTCSeconds());
document.getElementById("now_remaining").innerHTML = twoDigit(this.remaining.getUTCHours()) + ":" + twoDigit(this.remaining.getUTCMinutes()) + ":" + twoDigit(this.remaining.getUTCSeconds());
document.getElementById("now_scala").style.width = (100 / this.duration.getTime() * this.elapsed.getTime()) + "%";
//plPrBar_debug('update');
document.getElementById("now_elapsed").innerHTML = twoDigit(this.c_elapsed.getUTCHours()) + ":" + twoDigit(this.c_elapsed.getUTCMinutes()) + ":" + twoDigit(this.c_elapsed.getUTCSeconds());
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() {
clearInterval(this.run);
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_request() {
plPrBar_debug('request');
jsCom("jscom_wrapper", ["uiBrowser", "SCHEDULER", "getScheduleInfo_jscom", "1"], this.create);
}
function plPrBar_create(jscomRes) {
if (jscomRes !== '') {
eval('var parms = ' + jscomRes + ';');
ppb = new plPrBar(parms[0],
parms[1], parms[2], parms[3],
parms[4], parms[5], parms[6],
parms[7], parms[8], parms[9], parms[10], parms[11],
parms[12]
);
ppb.init();
} else {
plPrBar_hide();
};
plPrBar_debug('create: ' + jscomRes);
window.clearInterval(ppb.progress);
if (jscomRes !== '') {
eval('var parms = ' + jscomRes + ';');
ppb = new plPrBar();
ppb.init(parms[0], parms[1], parms[2], parms[3], parms[4], parms[5], parms[6], parms[7], parms[8],
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]);
} else {
plPrBar_hide('now');
plPrBar_hide('next');
plPrBar_hide('upcoming');
};
setTimeout("ppb.request()", 10000);
}
function plPrBar_show() {
document.getElementById("nowplaying_indicator").innerHTML = '<div id="onair">##Playing Scheduled Item##</div>';
function plPrBar_onair() {
plPrBar_debug('onair');
document.getElementById("offair").style.display = 'none';
document.getElementById("onair").style.display = 'block';
}
function plPrBar_hide() {
document.getElementById("nowplaying_indicator").innerHTML = '<div id="offair">##Off Air##</div>';
document.getElementById("nowplaying").innerHTML = "";
function plPrBar_offair() {
plPrBar_debug('offair');
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}
{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()}
ppb_debug = false;
ppb = new plPrBar();
ppb.request();
//interval = setInterval("ppb.request();", 10000);
</script>

View File

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

View File

@ -142,7 +142,7 @@ class uiScheduler extends uiCalendar {
$this->curr['hour'] = sprintf('%02d', $hour);
}
$stampNow = uiScheduler::datetimeToTimestamp($this->curr['year']
$stampNow = self::datetimeToTimestamp($this->curr['year']
.$this->curr['month']
.$this->curr['day']
.'T'.$this->curr['hour'].':00:00');
@ -246,7 +246,7 @@ class uiScheduler extends uiCalendar {
$this->scheduleNext['minute'] = 59;
$this->scheduleNext['second'] = 59;
$this->scheduleAtTime['stamp'] = uiScheduler::datetimeToTimestamp(
$this->scheduleAtTime['stamp'] = self::datetimeToTimestamp(
$this->scheduleAtTime['year']
.$this->scheduleAtTime['month']
.$this->scheduleAtTime['day']
@ -311,15 +311,15 @@ class uiScheduler extends uiCalendar {
$items = array();
foreach ($arr as $key => $val) {
$id = BasicStor::IdFromGunid($val['playlistId']);
$startDay = strftime('%d', uiScheduler::datetimeToTimestamp($val['start']));
$startHour = number_format(strftime('%H', uiScheduler::datetimeToTimestamp($val['start'])));
$startDay = strftime('%d', self::datetimeToTimestamp($val['start']));
$startHour = number_format(strftime('%H', self::datetimeToTimestamp($val['start'])));
$items[$startDay][$startHour][]= array (
'id' => $id,
'scheduleid'=> $val['id'],
'start' => substr($val['start'], strpos($val['start'], 'T')+1),
'end' => substr($val['end'], strpos($val['end'], 'T')+1),
'start_stamp' => uiScheduler::datetimeToTimestamp($val['start']),
'end_stamp' => uiScheduler::datetimeToTimestamp($val['end']),
'start_stamp' => self::datetimeToTimestamp($val['start']),
'end_stamp' => self::datetimeToTimestamp($val['end']),
'title' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE),
'creator' => $this->Base->getMetadataValue($id, UI_MDATA_KEY_CREATOR),
'type' => 'Playlist'
@ -348,8 +348,8 @@ class uiScheduler extends uiCalendar {
$items = array();
foreach ($arr as $key => $val) {
$start = uiScheduler::datetimeToTimestamp($val['start']);
$end = uiScheduler::datetimeToTimestamp($val['end']);
$start = self::datetimeToTimestamp($val['start']);
$end = self::datetimeToTimestamp($val['end']);
$Y = strftime('%Y', $start);
$m = number_format(strftime('%m', $start));
$d = number_format(strftime('%d', $start));
@ -447,7 +447,7 @@ class uiScheduler extends uiCalendar {
if (!count($arr))
return FALSE;
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),
'end' => substr($val['end'], strpos($val['end'], 'T') + 1),
'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']);
$arr[$key]['title'] = $this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE);
$arr[$key]['creator'] = $this->Base->getMetadataValue($id, UI_MDATA_KEY_CREATOR);
$arr[$key]['pos'] = uiScheduler::datetimeToTimestamp($val['start']);
$arr[$key]['span'] = date('H', uiScheduler::datetimeToTimestamp($val['end'])) - date('H', uiScheduler::datetimeToTimestamp($val['start'])) +1;
$arr[$key]['pos'] = self::datetimeToTimestamp($val['start']);
$arr[$key]['span'] = date('H', self::datetimeToTimestamp($val['end'])) - date('H', self::datetimeToTimestamp($val['start'])) +1;
}
return $arr;
} // fn getDayUsage
@ -496,7 +496,7 @@ class uiScheduler extends uiCalendar {
$duration = 0;
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;
} // 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.
*
* @param int $distance
* 0=current clip; 1=next clip ...
* @param int $p_playlist_nr
* 0=current pl; 1=next pl ...
* @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');
$xmldatetime = str_replace('-', '', $datetime);
$pl = $this->displayScheduleMethod($xmldatetime, $xmldatetime);
$now = time();
$start = strftime('%Y%m%dT%H:%M:%S', $now);
$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;
}
$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
$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']) {
return FALSE;
@ -631,34 +656,84 @@ class uiScheduler extends uiCalendar {
'percentage'=> $percentage,
'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
if ($curr = $this->getNowNextClip()) {
$next = $this->getNowNextClip(1);
return array(
'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;
$c_pl = self::getScheduledPlaylist();
if ($c_clip = $this->getClipFromCurrent($c_pl, 0)) {
$n_clip = $this->getClipFromCurrent($c_pl, 1);
}
} // 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);
$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
@ -738,11 +813,11 @@ class uiScheduler extends uiCalendar {
$pStampArr = null;
foreach ($pArr as $val) {
$pStampArr[] = array('start' => uiScheduler::datetimeToTimestamp($val['start']),
'end' => uiScheduler::datetimeToTimestamp($val['end']));
$pStampArr[] = array('start' => self::datetimeToTimestamp($val['start']),
'end' => self::datetimeToTimestamp($val['end']));
}
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) {
if ($val['start'] < $n+86400 && $val['end'] >= $n) {
$days[date('Ymd', $n)] = array('year' => date('Y', $n),

View File

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