play

package
v0.0.0-...-bf164db Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Audio

type Audio struct {
	io.ReadCloser
	Format Format
}

Audio is a stream of bytes containing encoded audio.

type Format

type Format int

Format is a string that signals the audio encoding (mp3, etc).

const (
	// MP3 encoding.
	MP3 Format = iota
	// FLAC encoding.
	FLAC
	// WAV encoding.
	WAV
)

func (Format) String

func (f Format) String() string

type Player

type Player struct {
	// contains filtered or unexported fields
}

Player plays audio streams.

func NewPlayer

func NewPlayer(l *log.Logger) *Player

NewPlayer returns a Player ready to play Audio streams.

func (*Player) Done

func (p *Player) Done()

Done stops the current playback without waiting for the audio to finish.

func (*Player) GetSamples

func (p *Player) GetSamples() [][2]float64

GetSamples returns a snapshot of the samples.

func (*Player) IsPlaying

func (p *Player) IsPlaying() bool

IsPlaying returns the state of the Player. Note that IsPlaying == false could mean either the audio has finished or is simply paused.

func (*Player) Pause

func (p *Player) Pause()

Pause the playback from a playing state.

func (*Player) Play

func (p *Player) Play(a Audio) error

Play the audio until the audio is finished or Done is called. Play is synchronous, returning when the audio is finished.

func (*Player) Resume

func (p *Player) Resume()

Resume the playback from a paused state.

type Playlist

type Playlist struct {
	// contains filtered or unexported fields
}

Playlist manages the playback of audio files.

func New

func New(files []string) *Playlist

New creates a new Playlist.

func (*Playlist) Back

func (p *Playlist) Back()

Back plays the previous song.

func (*Playlist) Done

func (p *Playlist) Done()

Done signals that we are finished with the currently playing song.

func (*Playlist) GetSamples

func (p *Playlist) GetSamples() [][2]float64

GetSamples returns the samples.

func (*Playlist) GetTags

func (p *Playlist) GetTags() Tag

GetTags gets the tag for the song.

func (*Playlist) IsPlaying

func (p *Playlist) IsPlaying() bool

IsPlaying reports the status of the Player.

func (*Playlist) Next

func (p *Playlist) Next()

Next plays the next song.

func (*Playlist) TogglePause

func (p *Playlist) TogglePause()

TogglePause toggles the playback state.

type Tag

type Tag struct {
	Artist string
	Title  string
}

Tag contains metadata about the song.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL