player

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package player provides a simple audio player based on Takeout server-based playlists. There's support for FLAC, OGG, MP3 and WAV audio decoding, along with Internet radio and ICY metadata. Internally Beep and Oto are used which are known to work on Linux, BSDs, macOS, Windows, and more.

Index

Constants

View Source
const (
	ActionNext playerAction = iota
	ActionSkipForward
	ActionSkipBackward
	ActionPause
	ActionStop
)

Variables

View Source
var (
	ErrInvalidMetadataLength = errors.New("icy metadata length is invalid")
	ErrInvalidIntervalLength = errors.New("icy metadata interval is invalid")

	HeaderIcyBr          = http.CanonicalHeaderKey("Icy-Br")
	HeaderIcyDescription = http.CanonicalHeaderKey("Icy-Description")
	HeaderIcyGenre       = http.CanonicalHeaderKey("Icy-Genre")
	HeaderIcyMetaData    = http.CanonicalHeaderKey("Icy-MetaData")
	HeaderIcyMetaInt     = http.CanonicalHeaderKey("Icy-MetaInt")
	HeaderIcyName        = http.CanonicalHeaderKey("Icy-Name")
	HeaderIcyPublic      = http.CanonicalHeaderKey("Icy-Pub")
	HeaderIcyUrl         = http.CanonicalHeaderKey("Icy-Url")
)

Functions

func Notify added in v0.11.4

func Notify(streamer beep.StreamSeekCloser, halfway NotifyFunc) *notify

Types

type Config

type Config struct {
	Repeat   bool
	Buffer   time.Duration
	OnTrack  func(*Player)
	OnListen func(*Player)
	OnPause  func(*Player)
	OnError  func(*Player, error)
}

func NewConfig

func NewConfig() *Config

type Icy

type Icy struct {
	OnMetadata func(IcyMetadata)
	// contains filtered or unexported fields
}

func NewIcyReader

func NewIcyReader(interval int, reader io.ReadCloser, onMetaData func(IcyMetadata)) *Icy

func (*Icy) Close

func (icy *Icy) Close() error

func (*Icy) Read

func (icy *Icy) Read(p []byte) (n int, err error)

type IcyHeaders

type IcyHeaders struct {
	Bitrate     int
	Description string
	Genre       string
	Interval    int
	Name        string
	Public      bool
	Url         string
}

type IcyMetadata

type IcyMetadata struct {
	StreamTitle string
	StreamUrl   string
}

type NotifyFunc added in v0.11.4

type NotifyFunc func()

type Player

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

func NewPlayer

func NewPlayer(context client.Context, playlist spiff.Playlist, config *Config) *Player

func (*Player) Album

func (p *Player) Album() string

func (*Player) Artist

func (p *Player) Artist() string

func (*Player) Context

func (p *Player) Context() client.Context

func (*Player) ETag added in v0.13.0

func (p *Player) ETag() string

func (*Player) Image

func (p *Player) Image() string

func (*Player) Index

func (p *Player) Index() int

func (*Player) IsMusic

func (p *Player) IsMusic() bool

func (*Player) IsPodcast

func (p *Player) IsPodcast() bool

func (*Player) IsStream

func (p *Player) IsStream() bool

func (*Player) Length

func (p *Player) Length() int

func (*Player) Next

func (p *Player) Next()

func (*Player) Pause

func (p *Player) Pause()

func (*Player) Position

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

func (*Player) SkipBackward added in v0.11.3

func (p *Player) SkipBackward()

func (*Player) SkipForward added in v0.11.3

func (p *Player) SkipForward()

func (*Player) Start

func (p *Player) Start()

func (*Player) Stop

func (p *Player) Stop()

func (*Player) Title

func (p *Player) Title() string

func (*Player) Track

func (p *Player) Track() (string, string, string, string)

Jump to

Keyboard shortcuts

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