Documentation ¶
Overview ¶
Package audio provides is a cross platform go audio library. It currently supports desktop and mobile using golang.org/x/mobile/exp/audio. To use this library on linux desktop, you will need an OpenAL library as an external dependency. You can get this on Ubuntu using:
sudo apt-get install libopenal-dev
Web support via Gopherjs is planned.
Index ¶
- func Preload() error
- type Format
- type Player
- func (p *Player) Close() error
- func (p *Player) Current() time.Duration
- func (p *Player) Pause() error
- func (p *Player) Play() error
- func (p *Player) Prepare(background bool, offset int64, force bool) error
- func (p *Player) Seek(background bool, offset time.Duration) error
- func (p *Player) SetVolume(vol float64)
- func (p *Player) Source() al.Source
- func (p *Player) State() State
- func (p *Player) Stop() error
- func (p *Player) Total(background bool) time.Duration
- func (p *Player) Volume() float64
- type ReadSeekCloser
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player is a basic audio player that plays PCM data. Operations on a nil *Player are no-op, a nil *Player can be used for testing purposes.
func NewPlayer ¶
func NewPlayer(src ReadSeekCloser, format Format, samplesPerSecond int64) (*Player, error)
NewPlayer returns a new Player. It initializes the underlying audio devices and the related resources. If zero values are provided for format and sample rate values, the player determines them from the source's WAV header. An error is returned if the format and sample rate can't be determined.
The audio package is only designed for small audio sources.
func NewSimplePlayer ¶
func (*Player) Close ¶
Close closes the device and frees the underlying resources used by the player. It should be called as soon as the player is not in-use anymore.
func (*Player) Current ¶
Current returns the current playback position of the audio that is being played.
func (*Player) Play ¶
Play buffers the source audio to the audio device and starts to play the source. If the player paused or stopped, it reuses the previously buffered resources to keep playing from the time it has paused or stopped.
func (*Player) Seek ¶
Seek moves the play head to the given offset relative to the start of the source.
func (*Player) SetVolume ¶
SetVolume sets the volume of the player. The range of the volume is [0, 1].
type ReadSeekCloser ¶
type ReadSeekCloser interface { io.ReadSeeker io.Closer }
ReadSeekCloser is an io.ReadSeeker and io.Closer.