Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(EAV-423): add actions to start and stop External in vMix #362

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading