mirror of
https://github.com/onyx-and-iris/meld-cli.git
synced 2025-07-12 02:11:46 +00:00
add stream/record toggle
This commit is contained in:
parent
d70e4f112c
commit
06330f8ed6
34
index.js
34
index.js
@ -6,8 +6,8 @@ import WebSocket from 'ws'
|
|||||||
import cli from './utils/cli.js'
|
import cli from './utils/cli.js'
|
||||||
import { sceneHelp, sceneList, sceneSwitch, sceneCurrent } from './utils/scene.js'
|
import { sceneHelp, sceneList, sceneSwitch, sceneCurrent } from './utils/scene.js'
|
||||||
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, streamStatus } from './utils/stream.js'
|
import { streamHelp, streamStart, streamStop, streamToggle, streamStatus } from './utils/stream.js'
|
||||||
import { recordHelp, recordStart, recordStop, recordStatus } from './utils/record.js'
|
import { recordHelp, recordStart, recordStop, recordToggle, recordStatus } from './utils/record.js'
|
||||||
|
|
||||||
const input = cli.input
|
const input = cli.input
|
||||||
const flags = cli.flags
|
const flags = cli.flags
|
||||||
@ -225,6 +225,21 @@ socket.onopen = function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
case 'toggle':
|
||||||
|
channel = new QWebChannel(socket, function (channel) {
|
||||||
|
streamToggle(channel)
|
||||||
|
.then((message) => {
|
||||||
|
console.log(message)
|
||||||
|
socket.close()
|
||||||
|
process.exit(0)
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(`${err}`)
|
||||||
|
socket.close()
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
break
|
||||||
case 'status':
|
case 'status':
|
||||||
channel = new QWebChannel(socket, function (channel) {
|
channel = new QWebChannel(socket, function (channel) {
|
||||||
streamStatus(channel)
|
streamStatus(channel)
|
||||||
@ -284,6 +299,21 @@ socket.onopen = function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
case 'toggle':
|
||||||
|
channel = new QWebChannel(socket, function (channel) {
|
||||||
|
recordToggle(channel)
|
||||||
|
.then((message) => {
|
||||||
|
console.log(message)
|
||||||
|
socket.close()
|
||||||
|
process.exit(0)
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(`${err}`)
|
||||||
|
socket.close()
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
break
|
||||||
case 'status':
|
case 'status':
|
||||||
channel = new QWebChannel(socket, function (channel) {
|
channel = new QWebChannel(socket, function (channel) {
|
||||||
recordStatus(channel)
|
recordStatus(channel)
|
||||||
|
@ -7,6 +7,9 @@ const commands = {
|
|||||||
stop: {
|
stop: {
|
||||||
desc: 'Stop recording'
|
desc: 'Stop recording'
|
||||||
},
|
},
|
||||||
|
toggle: {
|
||||||
|
desc: 'Toggle recording state'
|
||||||
|
},
|
||||||
status: {
|
status: {
|
||||||
desc: 'Show the current recording status'
|
desc: 'Show the current recording status'
|
||||||
}
|
}
|
||||||
@ -70,6 +73,23 @@ function recordStop (channel) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function recordToggle (channel) {
|
||||||
|
if (!channel.objects || !channel.objects.meld) {
|
||||||
|
return Promise.reject(new Error('Meld object not found in channel.'))
|
||||||
|
}
|
||||||
|
|
||||||
|
const meld = channel.objects.meld
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
meld.toggleRecord()
|
||||||
|
.then(() => {
|
||||||
|
resolve(`Recording ${meld.isRecording ? 'stopped' : 'started'} successfully.`)
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
reject(err)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function recordStatus (channel) {
|
function recordStatus (channel) {
|
||||||
if (!channel.objects || !channel.objects.meld) {
|
if (!channel.objects || !channel.objects.meld) {
|
||||||
return Promise.reject(new Error('Meld object not found in channel.'))
|
return Promise.reject(new Error('Meld object not found in channel.'))
|
||||||
@ -83,5 +103,6 @@ export {
|
|||||||
recordHelp,
|
recordHelp,
|
||||||
recordStart,
|
recordStart,
|
||||||
recordStop,
|
recordStop,
|
||||||
|
recordToggle,
|
||||||
recordStatus
|
recordStatus
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,9 @@ const commands = {
|
|||||||
stop: {
|
stop: {
|
||||||
desc: 'Stop streaming'
|
desc: 'Stop streaming'
|
||||||
},
|
},
|
||||||
|
toggle: {
|
||||||
|
desc: 'Toggle streaming state'
|
||||||
|
},
|
||||||
status: {
|
status: {
|
||||||
desc: 'Show the current streaming status'
|
desc: 'Show the current streaming status'
|
||||||
}
|
}
|
||||||
@ -70,6 +73,23 @@ function streamStop (channel) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function streamToggle (channel) {
|
||||||
|
if (!channel.objects || !channel.objects.meld) {
|
||||||
|
return Promise.reject(new Error('Meld object not found in channel.'))
|
||||||
|
}
|
||||||
|
|
||||||
|
const meld = channel.objects.meld
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
meld.toggleStream()
|
||||||
|
.then(() => {
|
||||||
|
resolve(`Streaming ${meld.isStreaming ? 'stopped' : 'started'} successfully.`)
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
reject(err)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function streamStatus (channel) {
|
function streamStatus (channel) {
|
||||||
if (!channel.objects || !channel.objects.meld) {
|
if (!channel.objects || !channel.objects.meld) {
|
||||||
return Promise.reject(new Error('Meld object not found in channel.'))
|
return Promise.reject(new Error('Meld object not found in channel.'))
|
||||||
@ -82,6 +102,7 @@ function streamStatus (channel) {
|
|||||||
export {
|
export {
|
||||||
streamStart,
|
streamStart,
|
||||||
streamStop,
|
streamStop,
|
||||||
|
streamToggle,
|
||||||
streamStatus,
|
streamStatus,
|
||||||
streamHelp
|
streamHelp
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user