forked from remogatto/mandala
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sound.go
37 lines (31 loc) · 987 Bytes
/
sound.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package mandala
type AudioPlayer struct {
// The native instance of the audio player
ap *audioPlayer
}
// CreateAudioPlayer instantiates a player for the given filename.
func NewAudioPlayer() (*AudioPlayer, error) {
ap, err := newAudioPlayer()
if err != nil {
return nil, err
}
return &AudioPlayer{ap}, nil
}
// Play tells the player to play the named track and send a value to
// doneCh when done. The channel can be nil, in that case nothing is
// sent to it.
func (ap *AudioPlayer) Play(buffer []byte, doneCh chan bool) {
ap.ap.play(buffer, doneCh)
}
// GetVolumeScale returns the [min,max] values for volume. If the
// device doesn't support volume controls, it returns an error.
func (ap *AudioPlayer) GetMaxVolumeLevel() (int, error) {
return ap.ap.getMaxVolumeLevel()
}
// SetVolume sets the volume for the player.
func (ap *AudioPlayer) SetVolumeLevel(value int) error {
return ap.ap.setVolumeLevel(value)
}
func (ap *AudioPlayer) Destroy() {
ap.ap.destroy()
}