mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-12 02:43:50 +00:00
Feat/studio clock (#60)
This commit is contained in:
@@ -63,6 +63,7 @@ export class EventTimer extends Timer {
|
||||
nextPublicEventId = null;
|
||||
numEvents = null;
|
||||
_eventlist = null;
|
||||
onAir = false;
|
||||
|
||||
constructor(httpServer, oscClient, config) {
|
||||
// call super constructor
|
||||
@@ -199,7 +200,7 @@ export class EventTimer extends Timer {
|
||||
// send current timer
|
||||
broadcastTimer() {
|
||||
// through websockets
|
||||
this.io.emit('timer', this.getObject());
|
||||
this.io.emit('timer', this.getTimes());
|
||||
|
||||
// through OSC, only if running
|
||||
if (this.state === 'start' || this.state === 'roll') {
|
||||
@@ -211,7 +212,7 @@ export class EventTimer extends Timer {
|
||||
|
||||
// broadcast state
|
||||
broadcastState(update = true) {
|
||||
this.io.emit('timer', this.getObject(update));
|
||||
this.io.emit('timer', this.getTimes(update));
|
||||
this.io.emit('playstate', this.state);
|
||||
this.io.emit('selected', {
|
||||
id: this.selectedEventId,
|
||||
@@ -224,6 +225,7 @@ export class EventTimer extends Timer {
|
||||
this.io.emit('publicnext-id', this.nextPublicEventId);
|
||||
this.io.emit('titles', this.titles);
|
||||
this.io.emit('publictitles', this.titlesPublic);
|
||||
this.io.emit('onAir', this.onAir);
|
||||
}
|
||||
|
||||
// broadcast message
|
||||
@@ -359,7 +361,7 @@ export class EventTimer extends Timer {
|
||||
);
|
||||
|
||||
// send state
|
||||
socket.emit('timer', this.getObject());
|
||||
socket.emit('timer', this.getTimes());
|
||||
socket.emit('playstate', this.state);
|
||||
socket.emit('selected-id', this.selectedEventId);
|
||||
socket.emit('next-id', this.nextEventId);
|
||||
@@ -385,7 +387,7 @@ export class EventTimer extends Timer {
|
||||
/*******************************************/
|
||||
// general playback state
|
||||
socket.on('get-state', () => {
|
||||
socket.emit('timer', this.getObject());
|
||||
socket.emit('timer', this.getTimes());
|
||||
socket.emit('playstate', this.state);
|
||||
socket.emit('selected-id', this.selectedEventId);
|
||||
socket.emit('next-id', this.nextEventId);
|
||||
@@ -400,7 +402,7 @@ export class EventTimer extends Timer {
|
||||
});
|
||||
|
||||
socket.on('get-timer', () => {
|
||||
socket.emit('timer', this.getObject());
|
||||
socket.emit('timer', this.getTimes());
|
||||
});
|
||||
|
||||
socket.on('increment-timer', (data) => {
|
||||
@@ -419,6 +421,15 @@ export class EventTimer extends Timer {
|
||||
socket.emit('playstate', this.state);
|
||||
});
|
||||
|
||||
socket.on('set-onAir', (data) => {
|
||||
this.onAir = data;
|
||||
this.broadcastThis('onAir', this.onAir);
|
||||
});
|
||||
|
||||
socket.on('get-onAir', () => {
|
||||
socket.emit('onAir', this.onAir);
|
||||
});
|
||||
|
||||
/*******************************************/
|
||||
// selection data
|
||||
socket.on('get-selected', () => {
|
||||
@@ -949,6 +960,14 @@ export class EventTimer extends Timer {
|
||||
`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Set onAir property of timer
|
||||
* @param {boolean} onAir - whether flag is active
|
||||
*/
|
||||
set onAir(onAir) {
|
||||
this.onAir = onAir;
|
||||
}
|
||||
|
||||
start() {
|
||||
// if there is nothing selected, no nothing
|
||||
if (this.selectedEventId == null) return;
|
||||
|
||||
@@ -139,8 +139,8 @@ export class Timer {
|
||||
return this.duration - this.current;
|
||||
}
|
||||
|
||||
// getObject
|
||||
getObject(update = true) {
|
||||
// get time object
|
||||
getTimes(update = true) {
|
||||
// update timer
|
||||
if (update) this.update();
|
||||
|
||||
|
||||
@@ -38,6 +38,12 @@ export const initiateOSC = (config) => {
|
||||
|
||||
// get second part (command)
|
||||
switch (path.toLowerCase()) {
|
||||
case 'onAir':
|
||||
global.timer.onAir = true;
|
||||
break;
|
||||
case 'offAir':
|
||||
global.timer.onAir = false;
|
||||
break;
|
||||
case 'start':
|
||||
case 'play':
|
||||
console.log('calling play');
|
||||
|
||||
@@ -4,6 +4,22 @@ export const pbGet = async (req, res) => {
|
||||
res.send(global.timer.playState);
|
||||
};
|
||||
|
||||
// Create controller for GET request to '/playback/onAir'
|
||||
// Turns onAir flag to true
|
||||
export const onAir = async (req, res) => {
|
||||
console.log('Setting onAir to true');
|
||||
global.timer.onAir = true;
|
||||
res.sendStatus(200);
|
||||
};
|
||||
|
||||
// Create controller for GET request to '/playback/onAir'
|
||||
// Turns onAir flag to true
|
||||
export const offAir = async (req, res) => {
|
||||
console.log('Setting onAir to false');
|
||||
global.timer.onAir = false;
|
||||
res.sendStatus(200);
|
||||
};
|
||||
|
||||
// Create controller for GET request to '/playback/start'
|
||||
// Starts timer object
|
||||
export const pbStart = async (req, res) => {
|
||||
|
||||
@@ -7,6 +7,12 @@ const playbackController = require('../controllers/playbackController');
|
||||
// create route between controller and '/playback/' endpoint
|
||||
router.get('/', playbackController.pbGet);
|
||||
|
||||
// create route between controller and '/playback/onAir' endpoint
|
||||
router.get('/onAir', playbackController.onAir);
|
||||
|
||||
// create route between controller and '/playback/offAir' endpoint
|
||||
router.get('/offAir', playbackController.offAir);
|
||||
|
||||
// create route between controller and '/playback/start' endpoint
|
||||
router.get('/start', playbackController.pbStart);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user