feat: osc goto

- renamed previous goto to gotoid
This commit is contained in:
cv
2021-05-15 23:50:44 +02:00
parent f38823e077
commit 5959053e94
2 changed files with 17 additions and 6 deletions
+6 -5
View File
@@ -461,18 +461,15 @@ class EventTimer extends Timer {
if (eventIndex === -1) return; if (eventIndex === -1) return;
this.pause(); this.pause();
this.loadEvent(eventIndex); this.loadEvent(eventIndex, true, true);
this.broadcastState();
} }
// Loads a given event // Loads a given event
// load timers // load timers
// load selectedEventIndex // load selectedEventIndex
// load titles // load titles
loadEvent(eventIndex, type = 'load') { loadEvent(eventIndex, type = 'load', broadcastChange = 'false') {
const e = this._eventlist[eventIndex]; const e = this._eventlist[eventIndex];
if (e == null) return; if (e == null) return;
const start = e.timeStart == null || e.timeStart === '' ? 0 : e.timeStart; const start = e.timeStart == null || e.timeStart === '' ? 0 : e.timeStart;
@@ -503,6 +500,10 @@ class EventTimer extends Timer {
// look for event after // look for event after
this._loadTitlesNext(); this._loadTitlesNext();
if (broadcastChange)
// broadcast current state
this.broadcastState();
} }
_loadTitlesNow() { _loadTitlesNow() {
+11 -1
View File
@@ -20,7 +20,7 @@ const initiateOSC = (config) => {
if (address !== 'ontime') return; if (address !== 'ontime') return;
// get second part (command) // get second part (command)
switch (path) { switch (path.toLocaleLowerCase()) {
case 'start': case 'start':
case 'play': case 'play':
console.log('calling play'); console.log('calling play');
@@ -60,6 +60,16 @@ const initiateOSC = (config) => {
break; break;
case 'goto': case 'goto':
console.log('calling goto with', args); console.log('calling goto with', args);
try {
let eventIndex = parseInt(args);
if (isNaN(eventIndex) || eventIndex <= 0) return;
global.timer.loadEvent(eventIndex - 1, undefined, true);
} catch (error) {
console.log('error calling goto: ', error);
}
break;
case 'gotoid':
console.log('calling gotoid with', args);
try { try {
global.timer.loadEventById(args.toLowerCase()); global.timer.loadEventById(args.toLowerCase());
} catch (error) { } catch (error) {