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(vMix): allow overriding vMix transition from a separate layer #356

Merged
merged 1 commit into from
Nov 27, 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 @@ -8,6 +8,7 @@ import {
TimelineContentTypeVMix,
TimelineContentVMixAny,
VMixInputType,
VMixTransitionType,
} from 'timeline-state-resolver-types'
import { VMixTimelineStateConverter } from '../vMixTimelineStateConverter'
import { VMixOutput, VMixStateDiffer } from '../vMixStateDiffer'
Expand Down Expand Up @@ -136,6 +137,74 @@ describe('VMixTimelineStateConverter', () => {
expect(result.reportedState.inputsAddedByUsAudio[prefixAddedInput(filePath)]).toBeUndefined()
})

it('allows overriding transitions in usual layer order', () => {
const converter = createTestee()
const result = converter.getVMixStateFromTimelineState(
wrapInTimelineState({
pgm0: wrapInTimelineObject('pgm0', {
deviceType: DeviceType.VMIX,
type: TimelineContentTypeVMix.PROGRAM,
input: 2,
}),
pgm1: wrapInTimelineObject('pgm1', {
deviceType: DeviceType.VMIX,
type: TimelineContentTypeVMix.PROGRAM,
transition: {
duration: 500,
effect: VMixTransitionType.Fade,
},
}),
}),
{
pgm0: wrapInMapping({
mappingType: MappingVmixType.Program,
}),
pgm1: wrapInMapping({
mappingType: MappingVmixType.Program,
}),
}
)
expect(result.reportedState.mixes[0]?.transition).toEqual({
duration: 500,
effect: VMixTransitionType.Fade,
})
expect(result.reportedState.mixes[0]?.program).toEqual(2)
})

it('does not allow overriding transitions in reverse layer order', () => {
const converter = createTestee()
const result = converter.getVMixStateFromTimelineState(
wrapInTimelineState({
pgm0: wrapInTimelineObject('pgm0', {
deviceType: DeviceType.VMIX,
type: TimelineContentTypeVMix.PROGRAM,
transition: {
duration: 500,
effect: VMixTransitionType.Fade,
},
}),
pgm1: wrapInTimelineObject('pgm1', {
deviceType: DeviceType.VMIX,
type: TimelineContentTypeVMix.PROGRAM,
input: 2,
}),
}),
{
pgm0: wrapInMapping({
mappingType: MappingVmixType.Program,
}),
pgm1: wrapInMapping({
mappingType: MappingVmixType.Program,
}),
}
)
expect(result.reportedState.mixes[0]?.transition).toEqual({
duration: 0,
effect: VMixTransitionType.Cut,
})
expect(result.reportedState.mixes[0]?.program).toEqual(2)
})

// TODO: maybe we can't trust the defaults when adding an input? Make this test pass eventually
// it('tracks audio state for mapped inputs added by us', () => {
// const converter = createTestee()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ export class VMixTimelineStateConverter {
this._switchToInput(content.input, deviceState, mixProgram, content.transition)
} else if (content.inputLayer) {
this._switchToInput(content.inputLayer, deviceState, mixProgram, content.transition, true)
} else if (content.transition) {
const mixState = deviceState.reportedState.mixes[mixProgram]
if (mixState) {
mixState.transition = content.transition
}
}
}
break
Expand Down Expand Up @@ -238,7 +243,7 @@ export class VMixTimelineStateConverter {
mixState.preview = mixState.program
mixState.program = input

mixState.transition = transition || { effect: VMixTransitionType.Cut, duration: 0 }
mixState.transition = transition ?? { effect: VMixTransitionType.Cut, duration: 0 }
mixState.layerToProgram = layerToProgram
}
}
Expand Down
Loading