add CLI flag to set stop after current
This commit is contained in:
+14
-13
@@ -3,19 +3,20 @@ package ipc
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
PingPath = "/ping"
|
||||
PlayPath = "/transport/play"
|
||||
PlayPausePath = "/transport/playpause"
|
||||
PausePath = "/transport/pause"
|
||||
StopPath = "/transport/stop"
|
||||
PreviousPath = "/transport/previous"
|
||||
NextPath = "/transport/next"
|
||||
TimePosPath = "/transport/timepos" // ?s=<seconds>
|
||||
SeekByPath = "/transport/seek-by" // ?s=<+/- seconds>
|
||||
VolumePath = "/volume" // ?v=<vol>
|
||||
VolumeAdjustPath = "/volume/adjust" // ?pct=<+/- percentage>
|
||||
ShowPath = "/window/show"
|
||||
QuitPath = "/window/quit"
|
||||
PingPath = "/ping"
|
||||
PlayPath = "/transport/play"
|
||||
PlayPausePath = "/transport/playpause"
|
||||
PausePath = "/transport/pause"
|
||||
StopPath = "/transport/stop"
|
||||
StopAfterCurrentPath = "/transport/stop-after-current"
|
||||
PreviousPath = "/transport/previous"
|
||||
NextPath = "/transport/next"
|
||||
TimePosPath = "/transport/timepos" // ?s=<seconds>
|
||||
SeekByPath = "/transport/seek-by" // ?s=<+/- seconds>
|
||||
VolumePath = "/volume" // ?v=<vol>
|
||||
VolumeAdjustPath = "/volume/adjust" // ?pct=<+/- percentage>
|
||||
ShowPath = "/window/show"
|
||||
QuitPath = "/window/quit"
|
||||
)
|
||||
|
||||
type Response struct {
|
||||
|
||||
@@ -48,6 +48,14 @@ func (c *Client) PlayPause() error {
|
||||
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 {
|
||||
return c.sendRequest(NextPath)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ type PlaybackHandler interface {
|
||||
Continue()
|
||||
SeekBackOrPrevious()
|
||||
SeekNext()
|
||||
SetStopAfterCurrent(bool)
|
||||
SeekSeconds(float64)
|
||||
SeekBySeconds(float64)
|
||||
Volume() int
|
||||
@@ -68,6 +69,9 @@ func (s *serverImpl) createHandler() http.Handler {
|
||||
m.HandleFunc(PausePath, s.makeSimpleEndpointHandler(s.pbHandler.Pause))
|
||||
m.HandleFunc(PlayPausePath, s.makeSimpleEndpointHandler(s.pbHandler.PlayPause))
|
||||
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(NextPath, s.makeSimpleEndpointHandler(s.pbHandler.SeekNext))
|
||||
m.HandleFunc(TimePosPath, s.makeFloatEndpointHandler("s", s.pbHandler.SeekSeconds))
|
||||
|
||||
Reference in New Issue
Block a user