Skip to content

Commit

Permalink
update gitignore, add yarn.lock, add prettier as dev dep, run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
josephdadams committed Jul 18, 2024
1 parent c1fc7f2 commit 4b06cf7
Show file tree
Hide file tree
Showing 10 changed files with 3,591 additions and 2,774 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/
/pkg
/pkg.tgz
*.log
.DS_Store
.DS_Store
.yarn/
16 changes: 7 additions & 9 deletions actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ exports.getActions = function (instance) {
instance.log('debug', `sending ${cmd}`)
if (instance.socket !== undefined && instance.socket.isConnected) {
instance.socket.send(cmd)
}
else {
} else {
instance.log('warn', 'Cannot send command. Socket not connected.')
}
}
Expand Down Expand Up @@ -76,9 +75,9 @@ exports.getActions = function (instance) {
id: 'Key',
type: 'textinput',
default: 'Key_Esc',
isVisible: ((_o, _d) => false),
isVisible: (_o, _d) => false,
useVariables: true,
}
},
],
callback: action_callback,
},
Expand All @@ -90,9 +89,9 @@ exports.getActions = function (instance) {
id: 'Key',
type: 'textinput',
default: 'Key_Right',
isVisible: ((_o, _d) => false),
isVisible: (_o, _d) => false,
useVariables: true,
}
},
],
callback: action_callback,
},
Expand All @@ -104,9 +103,9 @@ exports.getActions = function (instance) {
id: 'Key',
type: 'textinput',
default: 'Key_Left',
isVisible: ((_o, _d) => false),
isVisible: (_o, _d) => false,
useVariables: true,
}
},
],
callback: action_callback,
},
Expand Down Expand Up @@ -141,7 +140,6 @@ exports.getActions = function (instance) {

ExitImages: { name: 'Still Image: Exit', options: [], callback: action_callback },


OpenStart_Presentation: {
name: 'Presentation: Open from file path',
options: [
Expand Down
6 changes: 3 additions & 3 deletions choices.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { numberOfPresentationSlots, numberOfMediaPlayerSlots } = require('./constants');
const { numberOfPresentationSlots, numberOfMediaPlayerSlots } = require('./constants')
exports.getChoicesForCapture = function () {
return [
{ id: 'Capture1', label: 'Image 1' },
Expand Down Expand Up @@ -35,15 +35,15 @@ exports.getChoicesForDisplay = function () {

exports.getChoicesForSlot = function () {
choicesList = []
for(let i = 1; i <= numberOfPresentationSlots; i++){
for (let i = 1; i <= numberOfPresentationSlots; i++) {
choicesList.push({ id: `Slot${i}`, label: i })
}
return choicesList
}

exports.getChoicesForMediaPlayer = function () {
choicesList = []
for(let i = 1; i <= numberOfMediaPlayerSlots; i++){
for (let i = 1; i <= numberOfMediaPlayerSlots; i++) {
choicesList.push({ id: `Load_MediaPlayer#${i}`, label: `Media ${i}` })
}
return choicesList
Expand Down
2 changes: 1 addition & 1 deletion constants.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
exports.numberOfPresentationSlots = 40
exports.numberOfMediaPlayerSlots = 40
exports.numberOfMediaPlayerSlots = 40
7 changes: 3 additions & 4 deletions feedbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ exports.getFeedbacks = function (instance) {
},
},


Media_playback_state_playing: {
type: 'boolean',
name: 'Media Player is playing',
Expand All @@ -167,7 +166,7 @@ exports.getFeedbacks = function (instance) {
return self.mediaPlayerState.playing
},
},

Media_playback_state_paused: {
type: 'boolean',
name: 'Media Player is paused',
Expand All @@ -181,7 +180,7 @@ exports.getFeedbacks = function (instance) {
return self.mediaPlayerState.paused
},
},

Media_player_loop_on: {
type: 'boolean',
name: 'Media Player loop-mode',
Expand All @@ -195,7 +194,7 @@ exports.getFeedbacks = function (instance) {
return self.mediaPlayerState.loop_on
},
},

Media_player_fade_on: {
type: 'boolean',
name: 'Media Player fade-mode',
Expand Down
52 changes: 26 additions & 26 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { InstanceBase, Regex, runEntrypoint, TCPHelper, InstanceStatus } = require('@companion-module/base')
const { numberOfPresentationSlots, numberOfMediaPlayerSlots } = require('./constants');
const { numberOfPresentationSlots, numberOfMediaPlayerSlots } = require('./constants')

var actions = require('./actions')
var feedbacks = require('./feedbacks')
Expand Down Expand Up @@ -36,7 +36,7 @@ class APSInstance extends InstanceBase {
}

async init(config) {
this.configUpdated(config);
this.configUpdated(config)
}

initTCP() {
Expand Down Expand Up @@ -80,7 +80,7 @@ class APSInstance extends InstanceBase {
self.receiver.push(data)
let messages = self.receiver.getMessages()
if (messages == null) return
for (let i = 0; i < messages.length; i++){
for (let i = 0; i < messages.length; i++) {
let message = messages[i]
try {
let jsonData = JSON.parse(message)
Expand Down Expand Up @@ -112,25 +112,25 @@ class APSInstance extends InstanceBase {
Presentation_next: jsonData.data.next,
}
// For not raising exception while using old verions of APS
if(jsonData.data.slide_number){
update_obj["slide_number"] = jsonData.data.slide_number
update_obj["slides_count"] = jsonData.data.slides_count
update_obj["Slides_builds_count"] = jsonData.data.builds_count
if (jsonData.data.slide_number) {
update_obj['slide_number'] = jsonData.data.slide_number
update_obj['slides_count'] = jsonData.data.slides_count
update_obj['Slides_builds_count'] = jsonData.data.builds_count
}
self.setVariableValues(update_obj)
} else if (jsonData.action === 'slots') {
self.setSlotVariables(jsonData.data)
states.updateSlotStates(self.slotStates, jsonData.data)
self.checkFeedbacks('slot_exist', 'slot_displayed')
}else if (jsonData.action === 'MediaPlayer') {
} else if (jsonData.action === 'MediaPlayer') {
self.setMediaPlayerVariables(jsonData.data)
states.updateMediaPlayerState(self.mediaPlayerState, jsonData.data)
self.checkFeedbacks(
'Media_playing',
'Media_loaded',
'Media_playback_state_playing',
'Media_playback_state_paused',
'Media_player_loop_on',
'Media_playing',
'Media_loaded',
'Media_playback_state_playing',
'Media_playback_state_paused',
'Media_player_loop_on',
'Media_player_fade_on',
)
}
Expand Down Expand Up @@ -171,8 +171,9 @@ class APSInstance extends InstanceBase {
type: 'static-text',
id: 'info-defaultport',
width: 12,
label: 'Check that the port in APS matches the target port shown here. To change the default port in APS, go to “Settings” in the app interface. Note that for earlier versions of APS, (2.2 and below) the default port is 4778. We recommend using port 31600 for connection. If this port is not available, try something else in the same range.',
}
label:
'Check that the port in APS matches the target port shown here. To change the default port in APS, go to “Settings” in the app interface. Note that for earlier versions of APS, (2.2 and below) the default port is 4778. We recommend using port 31600 for connection. If this port is not available, try something else in the same range.',
},
]
}

Expand Down Expand Up @@ -271,18 +272,17 @@ class APSInstance extends InstanceBase {
self.setVariableValues(values)
}


setMediaPlayerVariables(data) {
var self = this
const values = {
'Media_playing': data.Media_playing,
'Media_loaded': data.Media_loaded,
'Media_playing_filename': data.Media_playing_filename,
'Media_loaded_filename': data.Media_loaded_filename,
'Media_playback_state': data.Media_playback_state,
'Media_time_left': data.Media_time_left,
'Media_time_elapsed': data.Media_time_elapsed,
'Media_time_duration': data.Media_duration,
Media_playing: data.Media_playing,
Media_loaded: data.Media_loaded,
Media_playing_filename: data.Media_playing_filename,
Media_loaded_filename: data.Media_loaded_filename,
Media_playback_state: data.Media_playback_state,
Media_time_left: data.Media_time_left,
Media_time_elapsed: data.Media_time_elapsed,
Media_time_duration: data.Media_duration,
}

try {
Expand Down Expand Up @@ -332,7 +332,7 @@ class MessageBuffer {

getMessages() {
const messages = []

while (!this.isFinished()) {
const delimiterIndex = this.buffer.indexOf(this.delimiter)
if (delimiterIndex !== -1) {
Expand All @@ -341,7 +341,7 @@ class MessageBuffer {
messages.push(message)
}
}
return messages.length > 0 ? messages : null;
return messages.length > 0 ? messages : null
}
}

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "presentationtools-aps",
"version": "2.3.0",
"version": "2.3.1",
"main": "index.js",
"prettier": "@companion-module/tools/.prettierrc.json",
"scripts": {
Expand All @@ -16,6 +16,7 @@
"@companion-module/base": "~1.5.1"
},
"devDependencies": {
"@companion-module/tools": "^1.4.2"
"@companion-module/tools": "^1.4.2",
"prettier": "^3.3.3"
}
}
Loading

0 comments on commit 4b06cf7

Please sign in to comment.