add virtualcam toggle

This commit is contained in:
onyx-and-iris 2025-07-01 17:03:28 +01:00
parent 90bf51f363
commit 6545221ccc
6 changed files with 53 additions and 16 deletions

View File

@ -8,8 +8,9 @@ import { sceneHelp, sceneList, sceneSwitch, sceneCurrent } from './utils/scene.j
import { audioHelp, audioList, audioMute, audioUnmute, audioToggle, audioStatus } from './utils/audio.js' import { audioHelp, audioList, audioMute, audioUnmute, audioToggle, audioStatus } from './utils/audio.js'
import { streamHelp, streamStart, streamStop, streamToggle, streamStatus } from './utils/stream.js' import { streamHelp, streamStart, streamStop, streamToggle, streamStatus } from './utils/stream.js'
import { recordHelp, recordStart, recordStop, recordToggle, recordStatus } from './utils/record.js' import { recordHelp, recordStart, recordStop, recordToggle, recordStatus } from './utils/record.js'
import { clipHelp, saveClip } from './utils/clip.js' import { clipHelp, clipSave } from './utils/clip.js'
import { screenshotHelp, takeScreenshot } from './utils/screenshot.js' import { screenshotHelp, screenshotTake } from './utils/screenshot.js'
import { virtualcamHelp, virtualcamToggle } from './utils/virtualcam.js'
const input = cli.input const input = cli.input
const flags = cli.flags const flags = cli.flags
@ -66,7 +67,8 @@ socket.onopen = function () {
stream: streamHelp, stream: streamHelp,
record: recordHelp, record: recordHelp,
clip: clipHelp, clip: clipHelp,
screenshot: screenshotHelp screenshot: screenshotHelp,
virtualcam: virtualcamHelp
} }
if (flags.help && helpMap[command]) { if (flags.help && helpMap[command]) {
@ -170,17 +172,24 @@ socket.onopen = function () {
} else if (command === 'clip') { } else if (command === 'clip') {
const clipCommand = input[1] const clipCommand = input[1]
if (clipCommand === 'save') { if (clipCommand === 'save') {
withChannel(socket, (channel) => saveClip(channel)) withChannel(socket, (channel) => clipSave(channel))
} else { } else {
printHelp(clipHelp) printHelp(clipHelp)
} }
} else if (command === 'screenshot') { } else if (command === 'screenshot') {
const screenshotCommand = input[1] const screenshotCommand = input[1]
if (screenshotCommand === 'take') { if (screenshotCommand === 'take') {
withChannel(socket, (channel) => takeScreenshot(channel)) withChannel(socket, (channel) => screenshotTake(channel))
} else { } else {
printHelp(screenshotHelp) printHelp(screenshotHelp)
} }
} else if (command === 'virtualcam') {
const virtualcamCommand = input[1]
if (virtualcamCommand === 'toggle') {
withChannel(socket, (channel) => virtualcamToggle(channel))
} else {
printHelp(virtualcamHelp)
}
} else { } else {
printHelp(cli.help) printHelp(cli.help)
socket.close() socket.close()

View File

@ -49,11 +49,6 @@
"docs", "docs",
"doc" "doc"
], ],
"env": {
"browser": true,
"node": true,
"es2021": true
},
"parserOptions": { "parserOptions": {
"ecmaVersion": 12, "ecmaVersion": 12,
"sourceType": "module" "sourceType": "module"

View File

@ -19,6 +19,9 @@ const commands = {
}, },
screenshot: { screenshot: {
desc: 'Take a screenshot' desc: 'Take a screenshot'
},
virtualcam: {
desc: 'Manage virtual camera settings'
} }
} }

View File

@ -18,9 +18,9 @@ const clipHelp = meowHelp({
defaults: false defaults: false
}) })
async function saveClip (channel) { async function clipSave (channel) {
await channel.objects.meld.sendCommand('meld.recordClip') await channel.objects.meld.sendCommand('meld.recordClip')
return 'Clip command sent successfully.' return 'Clip saved successfully.'
} }
export { clipHelp, saveClip } export { clipHelp, clipSave }

View File

@ -18,9 +18,9 @@ const screenshotHelp = meowHelp({
defaults: false defaults: false
}) })
async function takeScreenshot (channel) { async function screenshotTake (channel) {
await channel.objects.meld.sendCommand('meld.screenshot') await channel.objects.meld.sendCommand('meld.screenshot')
return 'Screenshot command sent successfully.' return 'Screenshot taken successfully.'
} }
export { screenshotHelp, takeScreenshot } export { screenshotHelp, screenshotTake }

30
utils/virtualcam.js Normal file
View File

@ -0,0 +1,30 @@
import meowHelp from 'cli-meow-help'
const commands = {
toggle: {
desc: 'Toggle the virtual camera on or off'
}
}
const flags = {
help: {
type: 'boolean',
shortFlag: 'h',
desc: 'Display help information'
}
}
const virtualcamHelp = meowHelp({
name: 'virtualcam',
flags,
commands,
desc: 'Manage virtual camera settings in Meld',
defaults: false
})
async function virtualcamToggle (channel) {
await channel.objects.meld.sendCommand('meld.toggleVirtualCameraAction')
return 'Virtual camera toggled successfully.'
}
export { virtualcamHelp, virtualcamToggle }