mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2025-06-10 05:30:34 +01:00
use ToggleRecord()/ToggleStream methods
This commit is contained in:
parent
3095c0c49d
commit
36d0753bd9
15
record.go
15
record.go
@ -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
|
||||||
}
|
}
|
||||||
|
12
stream.go
12
stream.go
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user