import "golang.org/x/mobile/exp/audio"
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.
Format represents a PCM data format.
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.
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.
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.
Current returns the current playback position of the audio that is being played.
Pause pauses the player.
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.
Seek moves the play head to the given offset relative to the start of the source.
SetVolume sets the volume of the player. The range of the volume is [0, 1].
State returns the player's current state.
Stop stops the player.
Total returns the total duration of the audio source.
Volume returns the current player volume. The range of the volume is [0, 1].
type ReadSeekCloser interface { io.ReadSeeker io.Closer }
ReadSeekCloser is an io.ReadSeeker and io.Closer.
State indicates the current playing state of the player.
Path | Synopsis |
---|---|
al | Package al provides OpenAL Soft bindings for Go. |
Package audio imports 7 packages (graph) and is imported by 3 packages. Updated 6 days ago. Refresh now. Tools for package owners.