parent
2a142c2688
commit
fbdaf64558
|
|
@ -5,42 +5,52 @@ const colorGreenMP = [88, 201, 23]
|
||||||
|
|
||||||
export function UpdateFeedbacks(self: MPinstance): void {
|
export function UpdateFeedbacks(self: MPinstance): void {
|
||||||
self.setFeedbackDefinitions({
|
self.setFeedbackDefinitions({
|
||||||
color_cue: {
|
color_task: {
|
||||||
name: 'PlayList Color Cue',
|
name: 'Color Task',
|
||||||
type: 'boolean',
|
type: 'advanced',
|
||||||
defaultStyle: {
|
|
||||||
bgcolor: combineRgb(255, 0, 0),
|
|
||||||
color: combineRgb(0, 0, 0),
|
|
||||||
},
|
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
id: 'current_Cue',
|
|
||||||
type: 'number',
|
|
||||||
label: 'ID',
|
|
||||||
default: 1,
|
|
||||||
min: 1,
|
|
||||||
max: 10000,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'pl',
|
|
||||||
type: 'textinput',
|
type: 'textinput',
|
||||||
label: 'Playlist UUID',
|
label: 'UUID',
|
||||||
|
id: 'uuid',
|
||||||
default: '',
|
default: '',
|
||||||
},
|
isVisible: () => (false),
|
||||||
|
}
|
||||||
],
|
],
|
||||||
callback: (feedback) => {
|
callback: (feedback) => {
|
||||||
console.log(
|
const uuid = feedback.options.uuid
|
||||||
'FEEDBACK | Color Cue: ' +
|
const colorStr = self.getVariableValue(`tl_${uuid}_color`) // string "16750848"
|
||||||
feedback.options.current_Cue + " >>> " +
|
if (typeof colorStr === 'string') {
|
||||||
feedback.options.pl + " >>> " +
|
const bgColor = parseInt(colorStr, 10)
|
||||||
self.states[`pl_${feedback.options.pl}_currentIndex`]
|
return {
|
||||||
+ " >>> " + (self.states[`pl_${feedback.options.pl}_currentIndex`] !== feedback.options.current_Cue)
|
bgcolor: bgColor,
|
||||||
)
|
}
|
||||||
if (self.states[`pl_${feedback.options.pl}_currentIndex`] !== feedback.options.current_Cue) {
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
color_cue: {
|
||||||
|
name: 'Color Cue',
|
||||||
|
type: 'advanced',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
type: 'textinput',
|
||||||
|
label: 'UUID',
|
||||||
|
id: 'uuid',
|
||||||
|
default: '',
|
||||||
|
isVisible: () => (false),
|
||||||
|
}
|
||||||
|
],
|
||||||
|
callback: (feedback) => {
|
||||||
|
const uuid = feedback.options.uuid
|
||||||
|
const colorStr = self.getVariableValue(`cue_${uuid}_color`) // string "16750848"
|
||||||
|
if (typeof colorStr === 'string') {
|
||||||
|
const bgColor = parseInt(colorStr, 10)
|
||||||
|
return {
|
||||||
|
bgcolor: bgColor,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
current_Cue: {
|
current_Cue: {
|
||||||
|
|
@ -64,6 +74,7 @@ export function UpdateFeedbacks(self: MPinstance): void {
|
||||||
type: 'textinput',
|
type: 'textinput',
|
||||||
label: 'Playlist UUID',
|
label: 'Playlist UUID',
|
||||||
default: '',
|
default: '',
|
||||||
|
isVisible: () => (false),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
callback: (feedback) => {
|
callback: (feedback) => {
|
||||||
|
|
|
||||||
32
src/main.ts
32
src/main.ts
|
|
@ -1,6 +1,7 @@
|
||||||
import { InstanceBase, runEntrypoint, InstanceStatus, SomeCompanionConfigField } from '@companion-module/base'
|
import { InstanceBase, runEntrypoint, InstanceStatus, SomeCompanionConfigField } from '@companion-module/base'
|
||||||
import { GetConfigFields, type ModuloPlayConfig } from './configFields.js'
|
import { GetConfigFields, type ModuloPlayConfig } from './configFields.js'
|
||||||
import { UpdateVariableDefinitions } from './variables.js'
|
import { UpdateVariableDefinitions } from './variables.js'
|
||||||
|
import { InitVariableDefinitions } from './variables.js'
|
||||||
import { UpgradeScripts } from './upgrades.js'
|
import { UpgradeScripts } from './upgrades.js'
|
||||||
import { UpdateActions } from './actions.js'
|
import { UpdateActions } from './actions.js'
|
||||||
import { UpdateFeedbacks } from './feedbacks.js'
|
import { UpdateFeedbacks } from './feedbacks.js'
|
||||||
|
|
@ -27,7 +28,7 @@ export class MPinstance extends InstanceBase<ModuloPlayConfig> {
|
||||||
moduloplayer: ModuloPlayer | undefined
|
moduloplayer: ModuloPlayer | undefined
|
||||||
spydog: SpyDog | undefined
|
spydog: SpyDog | undefined
|
||||||
|
|
||||||
public pollAPI: NodeJS.Timer | null = null
|
public pollAPI: NodeJS.Timeout | null = null
|
||||||
|
|
||||||
// MODULO PLAYER DATA
|
// MODULO PLAYER DATA
|
||||||
public tasksList = []
|
public tasksList = []
|
||||||
|
|
@ -125,6 +126,7 @@ export class MPinstance extends InstanceBase<ModuloPlayConfig> {
|
||||||
|
|
||||||
updatPolling() {
|
updatPolling() {
|
||||||
if (this.mpConnected) this.moduloplayer?.getPlaylistsCurrentCues()
|
if (this.mpConnected) this.moduloplayer?.getPlaylistsCurrentCues()
|
||||||
|
if (this.mpConnected) this.moduloplayer?.getTaskListModuloPlayer()
|
||||||
if (this.mpConnected) this.moduloplayer?.getPlaylistModuloPlayer()
|
if (this.mpConnected) this.moduloplayer?.getPlaylistModuloPlayer()
|
||||||
if (this.sdConnected) this.spydog?.getDynamicInfo()
|
if (this.sdConnected) this.spydog?.getDynamicInfo()
|
||||||
}
|
}
|
||||||
|
|
@ -144,7 +146,35 @@ export class MPinstance extends InstanceBase<ModuloPlayConfig> {
|
||||||
|
|
||||||
updateVariableDefinitions(): void {
|
updateVariableDefinitions(): void {
|
||||||
UpdateVariableDefinitions(this)
|
UpdateVariableDefinitions(this)
|
||||||
|
InitVariableDefinitions(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanUUID(uuid: String) {
|
||||||
|
return uuid.replaceAll("{", "").replaceAll("}", "")
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanName(name: String) {
|
||||||
|
return name.replaceAll(" ", "-")
|
||||||
|
}
|
||||||
|
|
||||||
|
getColorFromHex(colorHex: any) {
|
||||||
|
let couleurRgb = [0, 0, 0]
|
||||||
|
if (colorHex !== '') {
|
||||||
|
couleurRgb = this.hexToRgb(`${colorHex}`)
|
||||||
|
}
|
||||||
|
return couleurRgb
|
||||||
|
}
|
||||||
|
|
||||||
|
hexToRgb(hex: any) {
|
||||||
|
const normal = hex.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i)
|
||||||
|
if (normal) return normal.slice(1).map((e: string) => parseInt(e, 16))
|
||||||
|
|
||||||
|
const shorthand = hex.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i)
|
||||||
|
if (shorthand) return shorthand.slice(1).map((e: string) => 0x11 * parseInt(e, 16))
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
runEntrypoint(MPinstance, UpgradeScripts)
|
runEntrypoint(MPinstance, UpgradeScripts)
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@ import { getPresets } from './presets.js'
|
||||||
|
|
||||||
// 100 = CURRENT CUE LIST
|
// 100 = CURRENT CUE LIST
|
||||||
// 110 = ACTION GOTO
|
// 110 = ACTION GOTO
|
||||||
// 200 = SPYDOG DYNAMIC INFO
|
|
||||||
// 201 = SPYDOG STATIC INFO
|
|
||||||
|
|
||||||
export class ModuloPlayer {
|
export class ModuloPlayer {
|
||||||
instance: MPinstance
|
instance: MPinstance
|
||||||
|
|
@ -20,7 +18,7 @@ export class ModuloPlayer {
|
||||||
|
|
||||||
public messageManager(data: String): void {
|
public messageManager(data: String): void {
|
||||||
const datas = JSON.parse(data.toString())
|
const datas = JSON.parse(data.toString())
|
||||||
this.instance.log('debug', 'MODULO PLAYER | MESSAGE MANAGER | DATA ID >>> ' + datas['id'])
|
//this.instance.log('debug', 'MODULO PLAYER | MESSAGE MANAGER | DATA ID >>> ' + datas['id'])
|
||||||
if (datas['id'] == 1) {
|
if (datas['id'] == 1) {
|
||||||
//console.log('debug', 'MODULO PLAYER | MESSAGE MANAGER | DATA >>> ' + data.toString())
|
//console.log('debug', 'MODULO PLAYER | MESSAGE MANAGER | DATA >>> ' + data.toString())
|
||||||
this.tasksListManager(datas['result'])
|
this.tasksListManager(datas['result'])
|
||||||
|
|
@ -35,69 +33,50 @@ export class ModuloPlayer {
|
||||||
|
|
||||||
// TASK LIST
|
// TASK LIST
|
||||||
public tasksListManager(obj: any): void {
|
public tasksListManager(obj: any): void {
|
||||||
this.instance.tasksList = obj
|
const tlInstance: any[] = this.instance.tasksList
|
||||||
//this.instance.log('info', 'MODULO PLAYER | TESK LIST MANAGER| TESKS LIST >>> ' + JSON.stringify(this.instance.tasksList))
|
const tlNew: any[] = obj
|
||||||
this.instance.setPresetDefinitions(getPresets(this.instance))
|
const checkTL = areJsonArraysEqual(tlInstance, tlNew)
|
||||||
|
this.instance.log('debug', `MODULO PLAYER | CHECK TL >>> ${checkTL}`)
|
||||||
|
if (!checkTL) {
|
||||||
|
this.instance.tasksList = obj
|
||||||
|
this.instance.setPresetDefinitions(getPresets(this.instance))
|
||||||
|
this.instance.updateInstance()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// PLAY LISTS CUES
|
// PLAY LISTS CUES
|
||||||
public playListCuesManager(obj: any): void {
|
public playListCuesManager(obj: any): void {
|
||||||
const plInstance: any[] = this.instance.playLists
|
const plInstance: any[] = this.instance.playLists
|
||||||
const plNew: any[] = obj
|
const plNew: any[] = obj
|
||||||
const checkPL = areJsonArraysEqual(plInstance, plNew)
|
const checkPL = areJsonArraysEqual(plInstance, plNew)
|
||||||
if (checkPL) {
|
this.instance.log('debug', `MODULO PLAYER | CHECK PL >>> ${checkPL}`)
|
||||||
|
if (!checkPL) {
|
||||||
} else {
|
|
||||||
this.instance.playLists = obj
|
this.instance.playLists = obj
|
||||||
this.instance.setPresetDefinitions(getPresets(this.instance))
|
this.instance.setPresetDefinitions(getPresets(this.instance))
|
||||||
this.instance.updateInstance()
|
this.instance.updateInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// this.instance.log(
|
|
||||||
// 'warn',
|
|
||||||
// 'MODULO PLAYER |PLAYLISTS & CUES MANAGER| PLAYLISTS >>> ' + JSON.stringify(this.instance.playLists, null, 4),
|
|
||||||
// )
|
|
||||||
// for (let plID = 0; plID < obj.length; plID++) {
|
|
||||||
// const cuesList: any[] = obj[plID]["cues"]
|
|
||||||
// // this.instance.log(
|
|
||||||
// // 'warn',
|
|
||||||
// // 'MODULO PLAYER |PLAYLISTS & CUES MANAGER | CUES LIST >>> ' + JSON.stringify(cuesList, null, 4),
|
|
||||||
// // )
|
|
||||||
// for (let cuesID = 0; cuesID < cuesList.length; cuesID++) {
|
|
||||||
// //const cue = cuesList[cuesID]
|
|
||||||
// // this.instance.log(
|
|
||||||
// // 'warn',
|
|
||||||
// // 'MODULO PLAYER |PLAYLISTS & CUES MANAGER | CUES >>> ' + JSON.stringify(cue, null, 4),
|
|
||||||
// // )
|
|
||||||
// // this.instance.setVariableDefinitions([
|
|
||||||
// // { variableId: `cue_${cue["uuid"]}_color`, name: 'Cue Color' },
|
|
||||||
// // // { variableId: 'variable2', name: 'My second variable' },
|
|
||||||
// // // { variableId: 'variable3', name: 'Another variable' },
|
|
||||||
|
|
||||||
// // ])
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// this.instance.setPresetDefinitions(getPresets(this.instance))
|
|
||||||
// this.instance.updateInstance()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET CURRENT CUE INDEX
|
// GET CURRENT CUE INDEX
|
||||||
async getPlaylistsCurrentCues() {
|
async getPlaylistsCurrentCues() {
|
||||||
this.instance.log('info', `MODULO PLAYER | GET PLAYLISTS CURRENT CUE !`)
|
//this.instance.log('info', `MODULO PLAYER | GET PLAYLISTS CURRENT CUE !`)
|
||||||
this.instance.mpConnection?.sendMessage('get.list.playlists', 100)
|
this.instance.mpConnection?.sendMessage('get.list.playlists', 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
async setPlayListCurrentCueIndex(obj: any) {
|
async setPlayListCurrentCueIndex(obj: any) {
|
||||||
const pls: any[] = obj
|
const pls: any[] = obj
|
||||||
for (let playlist = 0; playlist < pls.length; playlist++) {
|
for (let playlist = 0; playlist < pls.length; playlist++) {
|
||||||
let uuid: String = pls[playlist]['uuid']//.slice(1, -1)
|
let uuid: String = this.instance.cleanUUID(pls[playlist]['uuid'])
|
||||||
this.instance.log('warn', `MODULO PLAYER | GET CURRENT INDEX >>> ${uuid} >>> ` + pls[playlist]['index'])
|
//this.instance.log('warn', `MODULO PLAYER | GET CURRENT INDEX >>> ${uuid} >>> ${pls[playlist]['index']} >>> ${pls[playlist]['grandMasterFader']}`)
|
||||||
|
let grandMasterFader = (pls[playlist]['grandMasterFader']*100).toFixed(0)
|
||||||
var obj: any = {
|
var obj: any = {
|
||||||
[`pl_${uuid}_currentIndex`]: parseInt(pls[playlist]['index']),
|
[`pl_${uuid}_currentIndex`]: parseInt(pls[playlist]['index']),
|
||||||
|
[`pl_${uuid}_grandMasterFader`]: grandMasterFader
|
||||||
}
|
}
|
||||||
this.instance.states[`pl_${uuid}_currentIndex`] = parseInt(pls[playlist]['index'])
|
this.instance.states[`pl_${uuid}_currentIndex`] = parseInt(pls[playlist]['index'])
|
||||||
|
this.instance.states[`pl_${uuid}_grandMasterFader`] = grandMasterFader
|
||||||
this.instance.setVariableValues(obj)
|
this.instance.setVariableValues(obj)
|
||||||
this.instance.checkFeedbacks()
|
this.instance.checkFeedbacks()
|
||||||
}
|
}
|
||||||
|
|
@ -129,12 +108,12 @@ export class ModuloPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTaskListModuloPlayer() {
|
async getTaskListModuloPlayer() {
|
||||||
this.instance.log('info', 'GET TASKS LIST')
|
//this.instance.log('info', 'GET TASKS LIST')
|
||||||
this.instance.mpConnection?.sendMessage('get.list.tasks', 1)
|
this.instance.mpConnection?.sendMessage('get.list.tasks', 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPlaylistModuloPlayer() {
|
async getPlaylistModuloPlayer() {
|
||||||
this.instance.log('info', 'GET PLAY LIST')
|
//this.instance.log('info', 'GET PLAY LIST')
|
||||||
this.instance.mpConnection?.sendMessagePlaylistsCues()
|
this.instance.mpConnection?.sendMessagePlaylistsCues()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ export class MPconnection {
|
||||||
if (this.websocket?.readyState === 1) {
|
if (this.websocket?.readyState === 1) {
|
||||||
var m = `{"jsonrpc":"2.0","method":"${method}","id": ${id}}`
|
var m = `{"jsonrpc":"2.0","method":"${method}","id": ${id}}`
|
||||||
this.websocket?.send(m)
|
this.websocket?.send(m)
|
||||||
this.instance.log('debug', 'SENDING WS MESSAGE ' + this.websocket.url + ' ' + m)
|
//this.instance.log('debug', 'SENDING WS MESSAGE ' + this.websocket.url + ' ' + m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,14 +100,14 @@ export class MPconnection {
|
||||||
"action": "launch"
|
"action": "launch"
|
||||||
},"id": ${id}}`
|
},"id": ${id}}`
|
||||||
this.websocket?.send(m)
|
this.websocket?.send(m)
|
||||||
this.instance.log('debug', 'SENDING WS MESSAGE LAUNCH TASK ' + this.websocket.url + ' ' + m)
|
//this.instance.log('debug', 'SENDING WS MESSAGE LAUNCH TASK ' + this.websocket.url + ' ' + m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendJsonMessage(message: String) {
|
sendJsonMessage(message: String) {
|
||||||
if (this.websocket?.readyState === 1 && message !== '') {
|
if (this.websocket?.readyState === 1 && message !== '') {
|
||||||
this.websocket?.send(message)
|
this.websocket?.send(message)
|
||||||
this.instance.log('debug', 'SENDING WS MESSAGE LAUNCH TASK ' + this.websocket.url + ' ' + message)
|
//this.instance.log('debug', 'SENDING WS MESSAGE LAUNCH TASK ' + this.websocket.url + ' ' + message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,7 +118,7 @@ export class MPconnection {
|
||||||
"level": "cue"},
|
"level": "cue"},
|
||||||
"id": 3}`
|
"id": 3}`
|
||||||
this.websocket?.send(m)
|
this.websocket?.send(m)
|
||||||
this.instance.log('debug', 'SENDING WS MESSAGE GET PLAYLISTS CUES ' + this.websocket.url + ' ' + m)
|
//this.instance.log('debug', 'SENDING WS MESSAGE GET PLAYLISTS CUES ' + this.websocket.url + ' ' + m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,19 +31,17 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions {
|
||||||
// TASK
|
// TASK
|
||||||
const getTasksPresets = (): mpPresetArray => {
|
const getTasksPresets = (): mpPresetArray => {
|
||||||
const tasksPresets: mpPresetArray = []
|
const tasksPresets: mpPresetArray = []
|
||||||
//instance.log("warn", "GET TASKS PRESETS 0 >>> " + instance.tasksList.length)
|
const tls: any[] = instance.tasksList
|
||||||
for (let task = 0; task < instance.tasksList.length; task++) {
|
for (let task = 0; task < tls.length; task++) {
|
||||||
let color = [0, 0, 0]
|
let color = instance.getColorFromHex(tls[task]['uiColor']) // [0, 0, 0]
|
||||||
if (instance.tasksList[task]['uiColor'] !== '') {
|
// if (tls[task]['uiColor'] !== '') { color = hexToRgb(`${tls[task]['uiColor']}`) }
|
||||||
color = hexToRgb(`${instance.tasksList[task]['uiColor']}`)
|
let uuid: String = instance.cleanUUID(tls[task]['uuid']) //.replaceAll("{", "").replaceAll("}", "")
|
||||||
}
|
|
||||||
//instance.log("warn", "GET TASKS PRESETS COLOR >>> " + color)
|
|
||||||
tasksPresets.push({
|
tasksPresets.push({
|
||||||
category: `Tasks List` as PresetCategory,
|
category: `Tasks List` as PresetCategory,
|
||||||
name: `${instance.tasksList[task]['name']}`,
|
name: `$(Modulo_Player:tl_${uuid}_name)`,
|
||||||
type: 'button',
|
type: 'button',
|
||||||
style: {
|
style: {
|
||||||
text: `${instance.tasksList[task]['name']}`,
|
text: `$(Modulo_Player:tl_${uuid}_name)`,
|
||||||
size: '24',
|
size: '24',
|
||||||
color: combineRgb(255, 255, 255),
|
color: combineRgb(255, 255, 255),
|
||||||
bgcolor: combineRgb(color[0], color[1], color[2]),
|
bgcolor: combineRgb(color[0], color[1], color[2]),
|
||||||
|
|
@ -60,21 +58,15 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
feedbacks: [
|
feedbacks: [
|
||||||
// {
|
{
|
||||||
// feedbackId: 'inputPreview',
|
feedbackId: 'color_task',
|
||||||
// options: {
|
options: {
|
||||||
// mix: (mix - 1) as MixOptionEntry,
|
uuid: uuid,
|
||||||
// mixVariable: '',
|
},
|
||||||
// input: input.toString(),
|
},
|
||||||
// fg: combineRgb(255, 255, 255),
|
|
||||||
// bg: combineRgb(0, 255, 0),
|
|
||||||
// tally: '',
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
//instance.log("warn", "GET TASKS PRESETS 1 >>> " + tasksPresets.length)
|
|
||||||
return tasksPresets
|
return tasksPresets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,26 +80,25 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions {
|
||||||
let uuid: String = pls[playlist]['uuid']//.slice(1, -1)
|
let uuid: String = pls[playlist]['uuid']//.slice(1, -1)
|
||||||
let plName = pls[playlist]['name']
|
let plName = pls[playlist]['name']
|
||||||
//instance.log('warn', 'GET CUES PRESETS >>> ' + uuid)
|
//instance.log('warn', 'GET CUES PRESETS >>> ' + uuid)
|
||||||
|
playlistsPresets.push({
|
||||||
|
category: `Playlists`,
|
||||||
|
name: `${plName}`,
|
||||||
|
type: 'text',
|
||||||
|
//text: 'Inputs 1 to 8',
|
||||||
|
})
|
||||||
for (let cue = 0; cue < cl.length; cue++) {
|
for (let cue = 0; cue < cl.length; cue++) {
|
||||||
|
const cuuid = instance.cleanUUID(cl[cue]['uuid'])
|
||||||
// COLOR
|
// COLOR
|
||||||
let color = [0, 0, 0]
|
let color = [0, 0, 0]
|
||||||
if (cl[cue]['uiColor'] !== '') {
|
if (cl[cue]['uiColor'] !== '') {
|
||||||
color = hexToRgb(`${cl[cue]['uiColor']}`)
|
color = hexToRgb(`${cl[cue]['uiColor']}`)
|
||||||
}
|
}
|
||||||
//instance.log('warn', 'GET CUES PRESETS COLOR >>> ' + color)
|
|
||||||
// NAME
|
|
||||||
let n = cl[cue]['name']
|
|
||||||
if (n === '') {
|
|
||||||
n = `Cue ${cue + 1}`
|
|
||||||
}
|
|
||||||
|
|
||||||
//instance.log('warn', 'GET CUES PRESETS NAME >>> ' + n)
|
|
||||||
playlistsPresets.push({
|
playlistsPresets.push({
|
||||||
category: `${pls[playlist]['name']}`,
|
category: `Playlists`,
|
||||||
name: n, //`${cl[cue]['name']}`,
|
name: `$(Modulo_Player:cue_${cuuid}_name)`, //n, //`${cl[cue]['name']}`,
|
||||||
type: 'button',
|
type: 'button',
|
||||||
style: {
|
style: {
|
||||||
text: n, //`${cl[cue]['name']}`,
|
text: `$(Modulo_Player:cue_${cuuid}_name)`, //n, //`${cl[cue]['name']}`,
|
||||||
size: textSize,
|
size: textSize,
|
||||||
color: combineRgb(255, 255, 255),
|
color: combineRgb(255, 255, 255),
|
||||||
bgcolor: combineRgb(color[0], color[1], color[2]),
|
bgcolor: combineRgb(color[0], color[1], color[2]),
|
||||||
|
|
@ -127,11 +118,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions {
|
||||||
{
|
{
|
||||||
feedbackId: 'color_cue',
|
feedbackId: 'color_cue',
|
||||||
options: {
|
options: {
|
||||||
current_Cue: cue + 1,
|
uuid: cuuid,
|
||||||
pl: uuid,
|
|
||||||
},
|
|
||||||
style: {
|
|
||||||
bgcolor: combineRgb(color[0], color[1], color[2]),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -150,7 +137,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions {
|
||||||
|
|
||||||
// GRAND MASTER 0%
|
// GRAND MASTER 0%
|
||||||
playlistsPresets.push({
|
playlistsPresets.push({
|
||||||
category: `${pls[playlist]['name']}`,
|
category: `Playlists`,
|
||||||
name: `${plName} GM 0`,
|
name: `${plName} GM 0`,
|
||||||
type: 'button',
|
type: 'button',
|
||||||
style: {
|
style: {
|
||||||
|
|
@ -175,7 +162,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions {
|
||||||
|
|
||||||
// GRAND MASTER 100%
|
// GRAND MASTER 100%
|
||||||
playlistsPresets.push({
|
playlistsPresets.push({
|
||||||
category: `${pls[playlist]['name']}`,
|
category: `Playlists`,
|
||||||
name: `${plName} GM`,
|
name: `${plName} GM`,
|
||||||
type: 'button',
|
type: 'button',
|
||||||
style: {
|
style: {
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ export class SDconnection {
|
||||||
sendJsonMessage(message: String) {
|
sendJsonMessage(message: String) {
|
||||||
if (this.websocket?.readyState === 1 && message !== '') {
|
if (this.websocket?.readyState === 1 && message !== '') {
|
||||||
this.websocket?.send(message)
|
this.websocket?.send(message)
|
||||||
this.instance.log('debug', 'SENDING WS MESSAGE LAUNCH TASK ' + this.websocket.url + ' ' + message)
|
//this.instance.log('debug', 'SPYDOD | SENDING WS MESSAGE LAUNCH TASK ' + this.websocket.url + ' ' + message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,36 @@
|
||||||
|
import { CompanionVariableValues, combineRgb } from '@companion-module/base/dist/index.js'
|
||||||
import type { MPinstance } from './main.js'
|
import type { MPinstance } from './main.js'
|
||||||
|
|
||||||
export function UpdateVariableDefinitions(instance: MPinstance): void {
|
export function UpdateVariableDefinitions(instance: MPinstance): void {
|
||||||
instance.log('info', 'VARIABLES DEFINITIONS !')
|
instance.log('info', 'VARIABLES DEFINITIONS !')
|
||||||
|
// CUES
|
||||||
const pls: any[] = instance.playLists
|
const pls: any[] = instance.playLists
|
||||||
const variables = []
|
const variables = []
|
||||||
for (let playlist = 0; playlist < pls.length; playlist++) {
|
for (let pl = 0; pl < pls.length; pl++) {
|
||||||
let uuid: String = pls[playlist]['uuid']//.slice(1, -1)
|
// CURRENT PL
|
||||||
//instance.log('warn', `VARIABLES DEFINITIONS | GET CURRENT INDEX >>> ${uuid} >>> ` + pls[playlist]['index'])
|
const cpl = pls[pl];
|
||||||
variables.push({ variableId: `pl_${uuid}_currentIndex`, name: `${pls[playlist]['name']} Current Cue ` })
|
const uuidPL: String = instance.cleanUUID(cpl['uuid'])
|
||||||
|
variables.push({ variableId: `pl_${uuidPL}_currentIndex`, name: `${cpl['name']} Current Cue ` })
|
||||||
|
variables.push({ variableId: `pl_${uuidPL}_grandMasterFader`, name: `${cpl['name']} Grand Master Fader ` })
|
||||||
|
|
||||||
|
// CUES LIST
|
||||||
|
const cueslist: any = cpl["cues"]
|
||||||
|
//instance.log('warn', `VARIABLES DEFINITIONS | GET CUES LIST >>> ${instance.playLists}`)
|
||||||
|
for (let cue = 0; cue < cueslist.length; cue++) {
|
||||||
|
const c = cueslist[cue];
|
||||||
|
const uuidCue: String = instance.cleanUUID(c['uuid'])
|
||||||
|
variables.push({ variableId: `cue_${uuidCue}_name`, name: `Cue Name` })
|
||||||
|
variables.push({ variableId: `cue_${uuidCue}_color`, name: `Cue Color` })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TASKS
|
||||||
|
const tls: any[] = instance.tasksList
|
||||||
|
for (let tl = 0; tl < tls.length; tl++) {
|
||||||
|
let tlUuid: String = instance.cleanUUID(tls[tl]['uuid'])
|
||||||
|
//instance.log('warn', `VARIABLES DEFINITIONS | GET TASK NAME >>> ${tlUuid} >>> ${tls[tl]['name']}`)
|
||||||
|
variables.push({ variableId: `tl_${tlUuid}_name`, name: `Task Name` })
|
||||||
|
variables.push({ variableId: `tl_${tlUuid}_color`, name: `Task Color` })
|
||||||
}
|
}
|
||||||
|
|
||||||
// SPYDOG STATIC INFO
|
// SPYDOG STATIC INFO
|
||||||
|
|
@ -42,10 +65,44 @@ export function UpdateVariableDefinitions(instance: MPinstance): void {
|
||||||
variables.push({ variableId: 'upTime', name: 'UP Time' })
|
variables.push({ variableId: 'upTime', name: 'UP Time' })
|
||||||
|
|
||||||
instance.setVariableDefinitions(variables)
|
instance.setVariableDefinitions(variables)
|
||||||
// instance.setVariableDefinitions([
|
}
|
||||||
// { variableId: 'variable1', name: 'My first variable' },
|
|
||||||
// { variableId: 'variable2', name: 'My second variable' },
|
export function InitVariableDefinitions(instance: MPinstance): void {
|
||||||
// { variableId: 'variable3', name: 'Another variable' },
|
instance.log('info', 'INIT VARIABLES DEFINITIONS !')
|
||||||
|
// CUES
|
||||||
// ])
|
const pls: any[] = instance.playLists
|
||||||
|
const variables: CompanionVariableValues = {};
|
||||||
|
for (let pl = 0; pl < pls.length; pl++) {
|
||||||
|
// CURRENT PL
|
||||||
|
const cpl = pls[pl];
|
||||||
|
// CUES LIST
|
||||||
|
const cueslist: any = cpl["cues"]
|
||||||
|
//instance.log('warn', `VARIABLES DEFINITIONS | GET CUES LIST >>> ${instance.playLists}`)
|
||||||
|
for (let cue = 0; cue < cueslist.length; cue++) {
|
||||||
|
const c = cueslist[cue];
|
||||||
|
const uuidCue: String = instance.cleanUUID(c['uuid'])
|
||||||
|
let n = c['name']
|
||||||
|
if (n === '') { n = `Cue ${cue + 1}` }
|
||||||
|
const id = `cue_${uuidCue}_name`
|
||||||
|
const idColor = `cue_${uuidCue}_color`
|
||||||
|
const couleurRgb = instance.getColorFromHex(`${c['uiColor']}`)
|
||||||
|
variables[id] = `${n}`;
|
||||||
|
variables[idColor] = combineRgb(couleurRgb[0], couleurRgb[1], couleurRgb[2]).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TASKS
|
||||||
|
const tls: any[] = instance.tasksList
|
||||||
|
for (let tl = 0; tl < tls.length; tl++) {
|
||||||
|
const tlUuid: String = instance.cleanUUID(tls[tl]['uuid'])
|
||||||
|
const tlName: String = tls[tl]['name']
|
||||||
|
//const tlColor: String = tls[tl]['uiColor']
|
||||||
|
const id = `tl_${tlUuid}_name`
|
||||||
|
const idColor = `tl_${tlUuid}_color`
|
||||||
|
const couleurRgb = instance.getColorFromHex(`${tls[tl]['uiColor']}`)
|
||||||
|
variables[id] = `${tlName}`;
|
||||||
|
variables[idColor] = combineRgb(couleurRgb[0], couleurRgb[1], couleurRgb[2]).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
instance.setVariableValues(variables)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue