add CLI flag to set stop after current
This commit is contained in:
@@ -548,6 +548,10 @@ func (a *App) checkFlagsAndSendIPCMsg(cli *ipc.Client) error {
|
|||||||
return cli.SeekBackOrPrevious()
|
return cli.SeekBackOrPrevious()
|
||||||
case *FlagNext:
|
case *FlagNext:
|
||||||
return cli.SeekNext()
|
return cli.SeekNext()
|
||||||
|
case *FlagStop:
|
||||||
|
return cli.Stop()
|
||||||
|
case *FlagStopAfterCurrent:
|
||||||
|
return cli.StopAfterCurrent()
|
||||||
case *FlagShow:
|
case *FlagShow:
|
||||||
return cli.Show()
|
return cli.Show()
|
||||||
case VolumeCLIArg >= 0:
|
case VolumeCLIArg >= 0:
|
||||||
|
|||||||
@@ -12,15 +12,17 @@ var (
|
|||||||
SeekByCLIArg float64 = 0
|
SeekByCLIArg float64 = 0
|
||||||
VolumePctCLIArg float64 = 0
|
VolumePctCLIArg float64 = 0
|
||||||
|
|
||||||
FlagPlay = flag.Bool("play", false, "unpause or begin playback")
|
FlagPlay = flag.Bool("play", false, "unpause or begin playback")
|
||||||
FlagPause = flag.Bool("pause", false, "pause playback")
|
FlagPause = flag.Bool("pause", false, "pause playback")
|
||||||
FlagPlayPause = flag.Bool("play-pause", false, "toggle play/pause state")
|
FlagPlayPause = flag.Bool("play-pause", false, "toggle play/pause state")
|
||||||
FlagPrevious = flag.Bool("previous", false, "seek to previous track or beginning of current")
|
FlagPrevious = flag.Bool("previous", false, "seek to previous track or beginning of current")
|
||||||
FlagNext = flag.Bool("next", false, "seek to next track")
|
FlagNext = flag.Bool("next", false, "seek to next track")
|
||||||
FlagStartMinimized = flag.Bool("start-minimized", false, "start app minimized")
|
FlagStop = flag.Bool("stop", false, "stop playback")
|
||||||
FlagShow = flag.Bool("show", false, "show minimized app")
|
FlagStopAfterCurrent = flag.Bool("stop-after-current", false, "stop playback after current track")
|
||||||
FlagVersion = flag.Bool("version", false, "print app version and exit")
|
FlagStartMinimized = flag.Bool("start-minimized", false, "start app minimized")
|
||||||
FlagHelp = flag.Bool("help", false, "print command line options and exit")
|
FlagShow = flag.Bool("show", false, "show minimized app")
|
||||||
|
FlagVersion = flag.Bool("version", false, "print app version and exit")
|
||||||
|
FlagHelp = flag.Bool("help", false, "print command line options and exit")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
+14
-13
@@ -3,19 +3,20 @@ package ipc
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PingPath = "/ping"
|
PingPath = "/ping"
|
||||||
PlayPath = "/transport/play"
|
PlayPath = "/transport/play"
|
||||||
PlayPausePath = "/transport/playpause"
|
PlayPausePath = "/transport/playpause"
|
||||||
PausePath = "/transport/pause"
|
PausePath = "/transport/pause"
|
||||||
StopPath = "/transport/stop"
|
StopPath = "/transport/stop"
|
||||||
PreviousPath = "/transport/previous"
|
StopAfterCurrentPath = "/transport/stop-after-current"
|
||||||
NextPath = "/transport/next"
|
PreviousPath = "/transport/previous"
|
||||||
TimePosPath = "/transport/timepos" // ?s=<seconds>
|
NextPath = "/transport/next"
|
||||||
SeekByPath = "/transport/seek-by" // ?s=<+/- seconds>
|
TimePosPath = "/transport/timepos" // ?s=<seconds>
|
||||||
VolumePath = "/volume" // ?v=<vol>
|
SeekByPath = "/transport/seek-by" // ?s=<+/- seconds>
|
||||||
VolumeAdjustPath = "/volume/adjust" // ?pct=<+/- percentage>
|
VolumePath = "/volume" // ?v=<vol>
|
||||||
ShowPath = "/window/show"
|
VolumeAdjustPath = "/volume/adjust" // ?pct=<+/- percentage>
|
||||||
QuitPath = "/window/quit"
|
ShowPath = "/window/show"
|
||||||
|
QuitPath = "/window/quit"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Response struct {
|
type Response struct {
|
||||||
|
|||||||
@@ -48,6 +48,14 @@ func (c *Client) PlayPause() error {
|
|||||||
return c.sendRequest(PlayPausePath)
|
return c.sendRequest(PlayPausePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) Stop() error {
|
||||||
|
return c.sendRequest(StopPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) StopAfterCurrent() error {
|
||||||
|
return c.sendRequest(StopAfterCurrentPath)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Client) SeekNext() error {
|
func (c *Client) SeekNext() error {
|
||||||
return c.sendRequest(NextPath)
|
return c.sendRequest(NextPath)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ type PlaybackHandler interface {
|
|||||||
Continue()
|
Continue()
|
||||||
SeekBackOrPrevious()
|
SeekBackOrPrevious()
|
||||||
SeekNext()
|
SeekNext()
|
||||||
|
SetStopAfterCurrent(bool)
|
||||||
SeekSeconds(float64)
|
SeekSeconds(float64)
|
||||||
SeekBySeconds(float64)
|
SeekBySeconds(float64)
|
||||||
Volume() int
|
Volume() int
|
||||||
@@ -68,6 +69,9 @@ func (s *serverImpl) createHandler() http.Handler {
|
|||||||
m.HandleFunc(PausePath, s.makeSimpleEndpointHandler(s.pbHandler.Pause))
|
m.HandleFunc(PausePath, s.makeSimpleEndpointHandler(s.pbHandler.Pause))
|
||||||
m.HandleFunc(PlayPausePath, s.makeSimpleEndpointHandler(s.pbHandler.PlayPause))
|
m.HandleFunc(PlayPausePath, s.makeSimpleEndpointHandler(s.pbHandler.PlayPause))
|
||||||
m.HandleFunc(StopPath, s.makeSimpleEndpointHandler(s.pbHandler.Stop))
|
m.HandleFunc(StopPath, s.makeSimpleEndpointHandler(s.pbHandler.Stop))
|
||||||
|
m.HandleFunc(StopAfterCurrentPath, s.makeSimpleEndpointHandler(func() {
|
||||||
|
s.pbHandler.SetStopAfterCurrent(true)
|
||||||
|
}))
|
||||||
m.HandleFunc(PreviousPath, s.makeSimpleEndpointHandler(s.pbHandler.SeekBackOrPrevious))
|
m.HandleFunc(PreviousPath, s.makeSimpleEndpointHandler(s.pbHandler.SeekBackOrPrevious))
|
||||||
m.HandleFunc(NextPath, s.makeSimpleEndpointHandler(s.pbHandler.SeekNext))
|
m.HandleFunc(NextPath, s.makeSimpleEndpointHandler(s.pbHandler.SeekNext))
|
||||||
m.HandleFunc(TimePosPath, s.makeFloatEndpointHandler("s", s.pbHandler.SeekSeconds))
|
m.HandleFunc(TimePosPath, s.makeFloatEndpointHandler("s", s.pbHandler.SeekSeconds))
|
||||||
|
|||||||
Reference in New Issue
Block a user