Documentation ¶
Overview ¶
Package audio provides a basic audio player.
In order to use this package on Linux desktop distros, you will need OpenAL library as an external dependency. On Ubuntu 14.04 'Trusty', you may have to install this library by running the command below.
sudo apt-get install libopenal-dev
When compiled for Android, this package uses OpenAL Soft as a backend. Please add its license file to the open source notices of your application. OpenAL Soft's license file could be found at http://repo.or.cz/w/openal-soft.git/blob/HEAD:/COPYING.
Index ¶
- 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) Seek(offset time.Duration) error
- func (p *Player) SetVolume(vol float64)
- func (p *Player) State() State
- func (p *Player) Stop() error
- func (p *Player) Total() time.Duration
- func (p *Player) Volume() float64
- type ReadSeekCloser
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 (*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.