player

package
v0.0.0-...-e988257 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: BSD-3-Clause, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSMFData  = errors.New("no SMF data is set")
	ErrIsPlaying  = errors.New("already playing")
	ErrIsStopped  = errors.New("already stopped")
	ErrInvalidSMF = errors.New("failed to read tracks from SMF data")
	ErrNoOutPort  = errors.New("failed to get sound out port")
)
View Source
var ErrUnavailable = errors.New("unavailable context")

Functions

func IgnoreError

func IgnoreError(f func() error)

IgnoreError will call function f and ignore error return. Useful to explicitly ignore errors in deferred functions.

func UnavailableContext

func UnavailableContext() context.Context

UnavailableContext returns a context that is already canceled

func WrapOnError

func WrapOnError(errInner error, errOuter error) error

WrapOnError will return nil if errInner is nil. Otherwise returns an error that wraps both errInner and errOuter.

Types

type Player

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

Player plays SMF data

func New

func New(outPort drivers.Out, stop context.Context) *Player

New returns a Player that plays on the given output port

func Play

func Play(out drivers.Out, smfdata io.Reader, done context.Context, tracks ...int) (*Player, error)

func PlaySMF

func PlaySMF(out drivers.Out, song *smf.SMF, done context.Context) (*Player, error)

func (*Player) Current

func (p *Player) Current() time.Duration

Current is the current time on the song.

func (*Player) Duration

func (p *Player) Duration() time.Duration

Duration is the total duration of the song.

func (*Player) IsPlaying

func (p *Player) IsPlaying() bool

IsPlaying returns wether the player is playing

func (*Player) Pause

func (p *Player) Pause() (err error)

Pause pauses the playing.

func (*Player) Remaining

func (p *Player) Remaining() time.Duration

Remaining is the remaining duration of the smf data.

func (*Player) SetSMF

func (p *Player) SetSMF(smfdata io.Reader, tracks ...int) error

SetSMF takes in a SMF and creates units that can be played.

func (*Player) SetSMFObj

func (p *Player) SetSMFObj(song *smf.SMF) error

func (*Player) Start

func (p *Player) Start() error

Start starts playing. It is non-blocking. Call wait to wait until it is finished.

func (*Player) Stop

func (p *Player) Stop() (err error)

Stop stops the playing.

func (*Player) Wait

func (p *Player) Wait()

Wait will block until the player finishes playing.

Jump to

Keyboard shortcuts

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