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

View File

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