use ToggleRecord()/ToggleStream methods

This commit is contained in:
onyx-and-iris 2025-05-07 20:17:26 +01:00
parent 3095c0c49d
commit 36d0753bd9
2 changed files with 7 additions and 20 deletions

View File

@ -44,24 +44,15 @@ type RecordToggleCmd struct{} // size = 0x0
// Run executes the command to toggle recording.
func (cmd *RecordToggleCmd) Run(ctx *context) error {
// Check if recording is in progress
status, err := ctx.Client.Record.GetRecordStatus()
status, err := ctx.Client.Record.ToggleRecord()
if err != nil {
return err
}
if status.OutputActive {
_, err = ctx.Client.Record.StopRecord()
if err != nil {
return err
}
fmt.Fprintln(ctx.Out, "Recording stopped successfully.")
} else {
_, err = ctx.Client.Record.StartRecord()
if err != nil {
return err
}
fmt.Fprintln(ctx.Out, "Recording started successfully.")
} else {
fmt.Fprintln(ctx.Out, "Recording stopped successfully.")
}
return nil
}

View File

@ -41,19 +41,15 @@ type StreamToggleCmd struct{} // size = 0x0
// Run executes the command to toggle streaming.
func (cmd *StreamToggleCmd) Run(ctx *context) error {
status, err := ctx.Client.Stream.GetStreamStatus()
status, err := ctx.Client.Stream.ToggleStream()
if err != nil {
return err
}
if status.OutputActive {
_, err = ctx.Client.Stream.StopStream()
fmt.Fprintf(ctx.Out, "Stopping stream...\n")
fmt.Fprintln(ctx.Out, "Streaming started successfully.")
} else {
_, err = ctx.Client.Stream.StartStream()
fmt.Fprintf(ctx.Out, "Starting stream...\n")
}
if err != nil {
return err
fmt.Fprintln(ctx.Out, "Streaming stopped successfully.")
}
return nil
}