refactor example in readme

This commit is contained in:
onyx-and-iris 2022-09-18 05:36:24 +01:00
parent 1284c92680
commit 21fb2ad597

View File

@ -42,12 +42,7 @@ import (
) )
func main() { func main() {
vm, err := voicemeeter.NewRemote("banana", 15) vm, err := vmConnect()
if err != nil {
log.Fatal(err)
}
err = vm.Login()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
@ -57,6 +52,20 @@ func main() {
vm.Strip[0].SetMute(true) vm.Strip[0].SetMute(true)
fmt.Printf("Strip 0 (%s) mute was set to %v\n", vm.Strip[0].GetLabel(), vm.Strip[0].GetMute()) fmt.Printf("Strip 0 (%s) mute was set to %v\n", vm.Strip[0].GetLabel(), vm.Strip[0].GetMute())
} }
func vmConnect() (*voicemeeter.Remote, error) {
vm, err := voicemeeter.NewRemote("banana", 15)
if err != nil {
return nil, err
}
err = vm.Login()
if err != nil {
return nil, err
}
return vm, nil
}
``` ```
## `voicemeeter.NewRemote(<kindId>, <delay>)` ## `voicemeeter.NewRemote(<kindId>, <delay>)`