mirror of
https://github.com/onyx-and-iris/meld-cli.git
synced 2026-04-09 02:43:35 +00:00
add stream/record toggle
This commit is contained in:
@@ -7,6 +7,9 @@ const commands = {
|
||||
stop: {
|
||||
desc: 'Stop recording'
|
||||
},
|
||||
toggle: {
|
||||
desc: 'Toggle recording state'
|
||||
},
|
||||
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) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error('Meld object not found in channel.'))
|
||||
@@ -83,5 +103,6 @@ export {
|
||||
recordHelp,
|
||||
recordStart,
|
||||
recordStop,
|
||||
recordToggle,
|
||||
recordStatus
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ const commands = {
|
||||
stop: {
|
||||
desc: 'Stop streaming'
|
||||
},
|
||||
toggle: {
|
||||
desc: 'Toggle streaming state'
|
||||
},
|
||||
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) {
|
||||
if (!channel.objects || !channel.objects.meld) {
|
||||
return Promise.reject(new Error('Meld object not found in channel.'))
|
||||
@@ -82,6 +102,7 @@ function streamStatus (channel) {
|
||||
export {
|
||||
streamStart,
|
||||
streamStop,
|
||||
streamToggle,
|
||||
streamStatus,
|
||||
streamHelp
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user