This commit is contained in:
a 2024-12-15 21:57:19 -06:00
parent a33d013525
commit f48f7df9e3
No known key found for this signature in database
GPG Key ID: 2F22877AA4DFDADB
2 changed files with 14 additions and 15 deletions

View File

@ -3,6 +3,7 @@ package commands
import (
"encoding/json"
"fmt"
"log"
"os"
"path/filepath"
@ -14,6 +15,11 @@ func (c *Commander) ListDevices() error {
if err != nil {
return err
}
playerState, err := c.Client().PlayerState(c.Context)
if err != nil {
return err
}
log.Printf("%+v\n", playerState)
return PrintDevices(devices)
}

View File

@ -9,22 +9,15 @@ import (
)
func (c *Commander) Play() error {
err := c.Client().Play(c.Context)
deviceID, err := c.activateDevice()
if err != nil {
if isNoActiveError(err) {
deviceID, err := c.activateDevice()
if err != nil {
return err
}
err = c.Client().PlayOpt(c.Context, &spotify.PlayOptions{
DeviceID: &deviceID,
})
if err != nil {
return err
}
} else {
return err
}
return err
}
err = c.Client().PlayOpt(c.Context, &spotify.PlayOptions{
DeviceID: &deviceID,
})
if err != nil {
return fmt.Errorf("play opt: %w", err)
}
return nil
}