Documentation ¶
Overview ¶
Package player provides a generic interface to play music from a github.com/frizinak/libym/collection.Queue.
Index ¶
- Variables
- type Backend
- type ErrorReporter
- type Player
- func (p *Player) Close() error
- func (p *Player) Duration() time.Duration
- func (p *Player) ForcePlay()
- func (p *Player) IncreaseVolume(n float64)
- func (p *Player) LoadPosition() error
- func (p *Player) Next()
- func (p *Player) Pause()
- func (p *Player) Paused() bool
- func (p *Player) Play()
- func (p *Player) Position() time.Duration
- func (p *Player) Prev()
- func (p *Player) SavePosition() error
- func (p *Player) Seek(n time.Duration, whence int)
- func (p *Player) SeekTo(n float64)
- func (p *Player) SetVolume(n float64)
- func (p *Player) Volume() float64
- type UnsupportedBackend
- func (u UnsupportedBackend) Close() error
- func (u UnsupportedBackend) Duration() time.Duration
- func (u UnsupportedBackend) IncreaseVolume(n float64)
- func (u UnsupportedBackend) Init() error
- func (u UnsupportedBackend) Pause(bool)
- func (u UnsupportedBackend) Paused() bool
- func (u UnsupportedBackend) Play(string) (chan struct{}, error)
- func (u UnsupportedBackend) Position() time.Duration
- func (u UnsupportedBackend) Seek(time.Duration, int)
- func (u UnsupportedBackend) SeekTo(float64)
- func (u UnsupportedBackend) SetVolume(float64)
- func (u UnsupportedBackend) Stop()
- func (u UnsupportedBackend) TogglePause()
- func (u UnsupportedBackend) Volume() float64
Constants ¶
This section is empty.
Variables ¶
var ErrNotSupported = errors.New("backend is not available, you will need to compile from source")
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { // Play should play the given string (file or url) // and send once on done to signal EOF. Play(string) (done chan struct{}, error error) // Paused must report if the player is paused. Paused() bool // Pause must pause the player. Pause(bool) // TogglePause should toggle the paused status. TogglePause() // SetVolume must update the player volume. argument is always // between 0 and 1. SetVolume(float64) // Increase volume should change the volume by the given delta. IncreaseVolume(float64) // Volume must report the current volume. Volume() float64 // Seek must seek to the given duration if whence == io.SeekStart and // Do a relative seek if whence == io.SeekCurrent. Seek(d time.Duration, whence int) // Seek must seek to the given position. argument is always // between 0 and 1. SeekTo(float64) // Position must report the current position in the file. Position() time.Duration // Position must report the total file duration. Duration() time.Duration // Stop must stop playing. Stop() // Close should release as many resources as possible as the Backend // wont be used any more. Close() error }
Backend is the grittier interface to an actual music player.
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player provides an interface to play songs from a collection.Queue given a Backend.
func NewPlayer ¶
func NewPlayer(backend Backend, reporter ErrorReporter, queue *collection.Queue, posFile string) *Player
NewPlayer constructs a new player.
func (*Player) Close ¶
Close releases resources and this player-backend pair should not be used anymore.
func (*Player) ForcePlay ¶
func (p *Player) ForcePlay()
ForcePlay as opposed to play, restarts playback of the active queue item. e.g.: if song A is currently playing and the active queue item is set to item B, B would be start after A is done playing. ForcePlay stops A and starts B.
func (*Player) IncreaseVolume ¶
IncreaseVolume changes the volume by the given delta (-1-1).
func (*Player) LoadPosition ¶ added in v0.9.0
func (*Player) Play ¶
func (p *Player) Play()
Play starts playback if nothing was playing or the player was paused.
func (*Player) SavePosition ¶ added in v0.9.0
func (*Player) Seek ¶
Seek seeks in the current file. whence == io.SeekStart: absolute seek whence == io.SeekCurrent: relative seek
type UnsupportedBackend ¶
type UnsupportedBackend struct{}
func (UnsupportedBackend) Close ¶
func (u UnsupportedBackend) Close() error
func (UnsupportedBackend) Duration ¶
func (u UnsupportedBackend) Duration() time.Duration
func (UnsupportedBackend) IncreaseVolume ¶
func (u UnsupportedBackend) IncreaseVolume(n float64)
func (UnsupportedBackend) Init ¶
func (u UnsupportedBackend) Init() error
func (UnsupportedBackend) Pause ¶
func (u UnsupportedBackend) Pause(bool)
func (UnsupportedBackend) Paused ¶
func (u UnsupportedBackend) Paused() bool
func (UnsupportedBackend) Play ¶
func (u UnsupportedBackend) Play(string) (chan struct{}, error)
func (UnsupportedBackend) Position ¶
func (u UnsupportedBackend) Position() time.Duration
func (UnsupportedBackend) SeekTo ¶
func (u UnsupportedBackend) SeekTo(float64)
func (UnsupportedBackend) SetVolume ¶
func (u UnsupportedBackend) SetVolume(float64)
func (UnsupportedBackend) Stop ¶
func (u UnsupportedBackend) Stop()
func (UnsupportedBackend) TogglePause ¶
func (u UnsupportedBackend) TogglePause()
func (UnsupportedBackend) Volume ¶
func (u UnsupportedBackend) Volume() float64