1package commands 2 3import ( 4 "fmt" 5 6 "github.com/ambientsound/pms/api" 7) 8 9// Stop stops song playback in MPD. 10type Stop struct { 11 newcommand 12 api api.API 13} 14 15// NewStop returns Stop. 16func NewStop(api api.API) Command { 17 return &Stop{ 18 api: api, 19 } 20} 21 22// Parse implements Command. 23func (cmd *Stop) Parse() error { 24 return cmd.ParseEnd() 25} 26 27// Exec implements Command. 28func (cmd *Stop) Exec() error { 29 if client := cmd.api.MpdClient(); client != nil { 30 return client.Stop() 31 } 32 return fmt.Errorf("Unable to stop: cannot communicate with MPD") 33} 34