Skip to content

Commit

Permalink
feat(EAV-423): add actions to start and stop External in vMix
Browse files Browse the repository at this point in the history
  • Loading branch information
ianshade committed Dec 6, 2024
1 parent ad41ae6 commit e002d0f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
8 changes: 6 additions & 2 deletions packages/timeline-state-resolver-types/src/generated/vmix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,16 @@ export interface SavePresetPayload {
export enum VmixActions {
LastPreset = 'lastPreset',
OpenPreset = 'openPreset',
SavePreset = 'savePreset'
SavePreset = 'savePreset',
StartExternal = 'startExternal',
StopExternal = 'stopExternal'
}
export interface VmixActionExecutionResults {
lastPreset: () => void,
openPreset: (payload: OpenPresetPayload) => void,
savePreset: (payload: SavePresetPayload) => void
savePreset: (payload: SavePresetPayload) => void,
startExternal: () => void,
stopExternal: () => void
}
export type VmixActionExecutionPayload<A extends keyof VmixActionExecutionResults> = Parameters<
VmixActionExecutionResults[A]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@
"required": ["filename"],
"additionalProperties": false
}
},
{
"id": "startExternal",
"name": "Start External Output",
"destructive": false,
"timeout": 5000
},
{
"id": "stopExternal",
"name": "Stop External Output",
"destructive": false,
"timeout": 5000
}
]
}
42 changes: 36 additions & 6 deletions packages/timeline-state-resolver/src/integrations/vmix/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,18 +300,18 @@ export class VMixDevice extends DeviceWithState<VMixStateExtended, DeviceOptions
return this._openPreset(payload as OpenPresetPayload) as Promise<VmixActionExecutionResult<A>>
case VmixActions.SavePreset:
return this._savePreset(payload as SavePresetPayload) as Promise<VmixActionExecutionResult<A>>
case VmixActions.StartExternal:
return this._startExternalOutput() as Promise<VmixActionExecutionResult<A>>
case VmixActions.StopExternal:
return this._stopExternalOutput() as Promise<VmixActionExecutionResult<A>>
default:
return actionNotFoundMessage(actionId)
}
}

_checkPresetAction(payload?: any, payloadRequired?: boolean): ActionExecutionResult | undefined {
if (!this._vMixConnection.connected) {
return {
result: ActionExecutionResultCode.Error,
response: t('Cannot perform VMix action without a connection'),
}
}
const connectionError = this._checkConnectionForAction()
if (connectionError) return connectionError

if (payloadRequired) {
if (!payload || typeof payload !== 'object') {
Expand Down Expand Up @@ -358,6 +358,36 @@ export class VMixDevice extends DeviceWithState<VMixStateExtended, DeviceOptions
}
}

private async _startExternalOutput() {
const connectionError = this._checkConnectionForAction()
if (connectionError) return connectionError

await this._vMixCommandSender.startExternal()
return {
result: ActionExecutionResultCode.Ok,
}
}

private async _stopExternalOutput() {
const connectionError = this._checkConnectionForAction()
if (connectionError) return connectionError

await this._vMixCommandSender.stopExternal()
return {
result: ActionExecutionResultCode.Ok,
}
}

private _checkConnectionForAction(): ActionExecutionResult | undefined {
if (!this._vMixConnection.connected) {
return {
result: ActionExecutionResultCode.Error,
response: t('Cannot perform VMix action without a connection'),
}
}
return undefined
}

get canConnect(): boolean {
return false
}
Expand Down

0 comments on commit e002d0f

Please sign in to comment.