mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-22 15:39:11 +00:00
@@ -6,8 +6,8 @@ export default function UnloadIconBtn(props) {
|
|||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton
|
||||||
icon={<FiXOctagon />}
|
icon={<FiXOctagon />}
|
||||||
colorScheme='whiteAlpha'
|
colorScheme='red'
|
||||||
backgroundColor='#ffffff05'
|
backgroundColor='#ff000022'
|
||||||
variant='outline'
|
variant='outline'
|
||||||
onClick={clickhandler}
|
onClick={clickhandler}
|
||||||
width={90}
|
width={90}
|
||||||
|
|||||||
@@ -16,17 +16,18 @@ const areEqual = (prevProps, nextProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const Playback = ({ playback, selectedId, playbackControl }) => {
|
const Playback = ({ playback, selectedId, playbackControl }) => {
|
||||||
|
const isRolling = playback === 'roll';
|
||||||
return (
|
return (
|
||||||
<div className={style.playbackContainer}>
|
<div className={style.playbackContainer}>
|
||||||
<StartIconBtn
|
<StartIconBtn
|
||||||
active={playback === 'start'}
|
active={playback === 'start'}
|
||||||
clickhandler={() => playbackControl('start')}
|
clickhandler={() => playbackControl('start')}
|
||||||
disabled={!selectedId}
|
disabled={!selectedId || isRolling}
|
||||||
/>
|
/>
|
||||||
<PauseIconBtn
|
<PauseIconBtn
|
||||||
active={playback === 'pause'}
|
active={playback === 'pause'}
|
||||||
clickhandler={() => playbackControl('pause')}
|
clickhandler={() => playbackControl('pause')}
|
||||||
disabled={!selectedId}
|
disabled={!selectedId || isRolling}
|
||||||
/>
|
/>
|
||||||
<RollIconBtn
|
<RollIconBtn
|
||||||
active={playback === 'roll'}
|
active={playback === 'roll'}
|
||||||
@@ -38,6 +39,7 @@ const Playback = ({ playback, selectedId, playbackControl }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const Transport = ({ playback, selectedId, playbackControl }) => {
|
const Transport = ({ playback, selectedId, playbackControl }) => {
|
||||||
|
const isRolling = playback === 'roll';
|
||||||
return (
|
return (
|
||||||
<div className={style.playbackContainer}>
|
<div className={style.playbackContainer}>
|
||||||
<PrevIconBtn
|
<PrevIconBtn
|
||||||
@@ -50,9 +52,12 @@ const Transport = ({ playback, selectedId, playbackControl }) => {
|
|||||||
/>
|
/>
|
||||||
<ReloadIconButton
|
<ReloadIconButton
|
||||||
clickhandler={() => playbackControl('reload')}
|
clickhandler={() => playbackControl('reload')}
|
||||||
disabled={!selectedId}
|
disabled={!selectedId || isRolling}
|
||||||
|
/>
|
||||||
|
<UnloadIconBtn
|
||||||
|
clickhandler={() => playbackControl('unload')}
|
||||||
|
disabled={!selectedId && !isRolling}
|
||||||
/>
|
/>
|
||||||
<UnloadIconBtn clickhandler={() => playbackControl('unload')} />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -203,8 +203,8 @@ export class EventTimer extends Timer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// broadcast state
|
// broadcast state
|
||||||
broadcastState() {
|
broadcastState(update = true) {
|
||||||
this.io.emit('timer', this.getObject());
|
this.io.emit('timer', this.getObject(update));
|
||||||
this.io.emit('playstate', this.state);
|
this.io.emit('playstate', this.state);
|
||||||
this.io.emit('selected', {
|
this.io.emit('selected', {
|
||||||
id: this.selectedEventId,
|
id: this.selectedEventId,
|
||||||
@@ -232,16 +232,28 @@ export class EventTimer extends Timer {
|
|||||||
if (this.state !== 'roll') {
|
if (this.state !== 'roll') {
|
||||||
super.update();
|
super.update();
|
||||||
} else {
|
} else {
|
||||||
// get current time
|
// update timer as usual
|
||||||
const now = this._getCurrentTime();
|
const now = this._getCurrentTime();
|
||||||
this.clock = now;
|
this.clock = now;
|
||||||
|
|
||||||
if (this.selectedEventId && this.current > 0) {
|
if (this.selectedEventId && this.current > 0) {
|
||||||
// update timer as usual
|
// something is running, update
|
||||||
this.current = this._finishAt - now;
|
this.current = this._finishAt - now;
|
||||||
} else {
|
} else if (this.secondaryTimer > 0) {
|
||||||
// look for event if none is loaded
|
// waiting to start, update secondary
|
||||||
if (this.current <= 0 || this.secondaryTimer <= 0) this.rollLoad();
|
this.secondaryTimer = this._secondaryTarget - now;
|
||||||
|
}
|
||||||
|
|
||||||
|
// look for event if none is loaded
|
||||||
|
const currentRunning = this.current <= 0 && this.current !== null;
|
||||||
|
const secondaryRunning =
|
||||||
|
this.secondaryTimer <= 0 && this.secondaryTimer !== null;
|
||||||
|
|
||||||
|
if (currentRunning || secondaryRunning) {
|
||||||
|
// look for events
|
||||||
|
this.rollLoad();
|
||||||
|
|
||||||
|
// broadcast state without recalculating timer
|
||||||
|
this.broadcastState(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,6 +573,11 @@ export class EventTimer extends Timer {
|
|||||||
? 'reload'
|
? 'reload'
|
||||||
: 'load';
|
: 'load';
|
||||||
this.loadEvent(this.selectedEventIndex, type);
|
this.loadEvent(this.selectedEventIndex, type);
|
||||||
|
} else if (e.id === this.nextEventId) {
|
||||||
|
// roll needs to recalculate
|
||||||
|
if (this.state === 'roll') {
|
||||||
|
this.rollLoad();
|
||||||
|
}
|
||||||
} else if ('title' in e || 'subtitle' in e || 'presenter') {
|
} else if ('title' in e || 'subtitle' in e || 'presenter') {
|
||||||
// TODO: should be more selective on the need to load titles
|
// TODO: should be more selective on the need to load titles
|
||||||
this._loadTitlesNext();
|
this._loadTitlesNext();
|
||||||
@@ -956,15 +973,25 @@ export class EventTimer extends Timer {
|
|||||||
// loop through events, look for where we should be
|
// loop through events, look for where we should be
|
||||||
for (const [index, e] of this._eventlist.entries()) {
|
for (const [index, e] of this._eventlist.entries()) {
|
||||||
if (!foundNow) {
|
if (!foundNow) {
|
||||||
if (e.timeStart <= now && now < e.timeEnd) {
|
let normalEnd = e.timeEnd;
|
||||||
|
|
||||||
|
// handle midnight
|
||||||
|
if (normalEnd < e.timeStart) {
|
||||||
|
normalEnd += this.DAYMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.timeStart <= now && now < normalEnd) {
|
||||||
// set flag
|
// set flag
|
||||||
foundNow = true;
|
foundNow = true;
|
||||||
|
|
||||||
// set timers
|
// set timers
|
||||||
|
this.secondaryTimer = null;
|
||||||
|
this._secondaryTarget = null;
|
||||||
|
|
||||||
this._startedAt = e.timeStart;
|
this._startedAt = e.timeStart;
|
||||||
this._finishAt = e.timeEnd;
|
this._finishAt = normalEnd;
|
||||||
this.duration = e.timeEnd - e.timeStart;
|
this.duration = normalEnd - e.timeStart;
|
||||||
this.current = e.timeEnd - now;
|
this.current = normalEnd - now;
|
||||||
|
|
||||||
// set selection
|
// set selection
|
||||||
this.selectedEventId = e.id;
|
this.selectedEventId = e.id;
|
||||||
@@ -987,23 +1014,29 @@ export class EventTimer extends Timer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nothing to play next, unload
|
// nothing to play, unload
|
||||||
if (foundNow == null && nextIndex == null) {
|
if (foundNow == null && nextIndex == null) {
|
||||||
this.unload();
|
this.unload();
|
||||||
console.log('Roll: no events found');
|
console.log('Roll: no events found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we found something to play next
|
||||||
if (nextIndex != null) {
|
if (nextIndex != null) {
|
||||||
// load titles
|
|
||||||
const e = this._eventlist[nextIndex];
|
const e = this._eventlist[nextIndex];
|
||||||
this._loadThisTitles(e, 'next');
|
this._loadThisTitles(e, 'next');
|
||||||
|
|
||||||
if (foundNow == null) {
|
if (foundNow == null) {
|
||||||
|
// only warn the first time
|
||||||
if (this.secondaryTimer == null)
|
if (this.secondaryTimer == null)
|
||||||
console.log('Roll: waiting for event start');
|
console.log('Roll: waiting for event start');
|
||||||
|
|
||||||
|
// reset running timer
|
||||||
|
this.current = null;
|
||||||
|
|
||||||
// timer counts to nextStart
|
// timer counts to nextStart
|
||||||
this.secondaryTimer = nextStart;
|
this.secondaryTimer = nextStart;
|
||||||
|
this._secondaryTarget = e.timeStart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1012,12 +1045,12 @@ export class EventTimer extends Timer {
|
|||||||
// do we need to change
|
// do we need to change
|
||||||
if (this.state === 'roll') return;
|
if (this.state === 'roll') return;
|
||||||
|
|
||||||
// load into event
|
|
||||||
this.rollLoad();
|
|
||||||
|
|
||||||
// set state
|
// set state
|
||||||
this.state = 'roll';
|
this.state = 'roll';
|
||||||
|
|
||||||
|
// load into event
|
||||||
|
this.rollLoad();
|
||||||
|
|
||||||
this.broadcastState();
|
this.broadcastState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export class Timer {
|
|||||||
current = null;
|
current = null;
|
||||||
timeTag = null;
|
timeTag = null;
|
||||||
secondaryTimer = null;
|
secondaryTimer = null;
|
||||||
|
_secondaryTarget = null;
|
||||||
_finishAt = null;
|
_finishAt = null;
|
||||||
_finishedAt = null;
|
_finishedAt = null;
|
||||||
_startedAt = null;
|
_startedAt = null;
|
||||||
@@ -125,6 +126,7 @@ export class Timer {
|
|||||||
this.current = this.duration;
|
this.current = this.duration;
|
||||||
this.running = null;
|
this.running = null;
|
||||||
this.secondaryTimer = null;
|
this.secondaryTimer = null;
|
||||||
|
this._secondaryTarget = null;
|
||||||
this._finishAt = null;
|
this._finishAt = null;
|
||||||
this._finishedAt = null;
|
this._finishedAt = null;
|
||||||
this._startedAt = null;
|
this._startedAt = null;
|
||||||
@@ -139,9 +141,9 @@ export class Timer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getObject
|
// getObject
|
||||||
getObject() {
|
getObject(update = true) {
|
||||||
// update timer
|
// update timer
|
||||||
this.update();
|
if (update) this.update();
|
||||||
|
|
||||||
// update timetag
|
// update timetag
|
||||||
this.timeTag = stringFromMillis(this.current);
|
this.timeTag = stringFromMillis(this.current);
|
||||||
|
|||||||
Reference in New Issue
Block a user