Documentation ¶
Overview ¶
Package player defines types and methods for defining a Tchaik player.
Index ¶
Constants ¶
const ( ActionPlay Action = "play" ActionPause = "pause" ActionNext = "next" ActionPrev = "prev" ActionTogglePlayPause = "togglePlayPause" ActionToggleRepeat = "toggleRepeat" ActionToggleMute = "toggleMute" )
Actions which don't need values.
const ( ActionSetVolume Action = "setVolume" ActionSetMute = "setMute" ActionSetRepeat = "setRepeat" ActionSetTime = "setTime" )
Player actions which require values.
Variables ¶
var RepActions = map[Action]string{
ActionPlay: "PLAY",
ActionPause: "PAUSE",
ActionNext: "NEXT",
ActionPrev: "PREV",
ActionTogglePlayPause: "TOGGLE_PLAY_PAUSE",
ActionToggleRepeat: "TOGGLE_REPEAT",
ActionToggleMute: "TOGGLE_MUTE",
ActionSetVolume: "SET_VOLUME",
ActionSetMute: "SET_MUTE",
ActionSetRepeat: "SET_REPEAT",
ActionSetTime: "SET_TIME",
}
Functions ¶
func NewHTTPHandler ¶
NewHTTPHandler returns an http.Handler which defines a REST API for interacting with Players.
Types ¶
type Action ¶
type Action string
Action is a type which represents an enumeration of available player actions.
func RepActionToAction ¶
RepActionToAction takes a string and returns an Action and true if the string represents a valid action, or Action("") and false otherwise. TODO(dhowden): This seems quite clunky??
type InvalidActionError ¶
type InvalidActionError string
InvalidActionError is an error returned when an invalid action has been received.
func (InvalidActionError) Error ¶
func (i InvalidActionError) Error() string
type InvalidValueError ¶
type InvalidValueError string
InvalidValueError is an error returned by value-setting methods.
type Player ¶
type Player interface { // Key returns a unique identifier for this Player. Key() string // Do sends a Action to the player. Do(a Action) error // SetMute enabled/disables mute. SetMute(bool) error // SetRepeat enable/disables a repeat of the current track. SetRepeat(bool) error // SetVolume sets the volume (value should be between 0.0 and 1.0). SetVolume(float64) error // SetTime sets the current play position SetTime(float64) error }
Player is an interface which defines methods for controlling a player.
func Multi ¶
Multi returns a Player that will apply calls to all provided Players in sequence. If an error is returning by a Player then it is returned immediately.
type Players ¶
Players is a collection of players which are identified by key.
func (*Players) MarshalJSON ¶
MarshalJSON implements json.Marshaler