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. // Run executes the command to toggle recording.
func (cmd *RecordToggleCmd) Run(ctx *context) error { func (cmd *RecordToggleCmd) Run(ctx *context) error {
// Check if recording is in progress status, err := ctx.Client.Record.ToggleRecord()
status, err := ctx.Client.Record.GetRecordStatus()
if err != nil { if err != nil {
return err return err
} }
if status.OutputActive { 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.") fmt.Fprintln(ctx.Out, "Recording started successfully.")
} else {
fmt.Fprintln(ctx.Out, "Recording stopped successfully.")
} }
return nil return nil
} }

View File

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