player

package
v0.0.0-...-e53a3c9 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatMp3  = 1
	FormatFlac = 2
)
View Source
const (
	// Player states
	// StopMedia -> Play -> Pause -> (Continue) -> StopMedia
	// Play new song
	Play State = iota
	// Continue paused song, only a transition mode, never state of the player
	Continue
	//SetVolume, only transition mode
	SetVolume
	// Pause song
	Pause
	// StopMedia playing
	Stop

	//SongComplete, only transition mode to notify song has changed
	SongComplete

	// Playing single song
	Song Playtype = 0
	// Playing album
	Album Playtype = 1
	// Playing artists discography
	Artist Playtype = 2
	// Playing playlist
	Playlist Playtype = 3

	// Last action was ok
	StatusOk Status = 0
	// Last action resulted in error
	StatusError Status = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	// What to do
	State  State
	Type   Playtype
	Volume int

	// Provide either artist/album/song or audio id
	Artist   string
	Album    string
	Song     string
	Year     int
	AudioId  string
	Duration int
}

Action includes instruction for player to play

type Format

type Format int

type PlaySong

type PlaySong struct {
	Action Action
	Song   io.ReadCloser
}

type Player

type Player struct {
	task.Task

	Api *api.Api
	// contains filtered or unexported fields
}

Player is the application structure

func NewPlayer

func NewPlayer(a *api.Api) (*Player, error)

NewPlayer constructs new player instance

func (*Player) ActionChannel

func (p *Player) ActionChannel() chan Action

ActionChannel returns input channel for user actions

func (*Player) AddSongChannel

func (p *Player) AddSongChannel() *chan PlaySong

func (*Player) PlaySong

func (p *Player) PlaySong(action Action) bool

func (*Player) RefreshState

func (p *Player) RefreshState()

RefreshState pushes current state into state channel

func (*Player) StateChannel

func (p *Player) StateChannel() chan PlayingState

StateChannel return output channel for player state

type PlayingState

type PlayingState struct {
	State       State
	PlayingType Playtype
	Song        string
	Artist      string
	Album       string
	Year        int

	// Content duration in sec
	CurrentSongDuration int
	CurrentSongPast     int
	PlaylistDuration    int
	PlaylistLeft        int
	// Volume [0,100]
	Volume int
}

PlayerState holds data about currently playing song if any

type Playtype

type Playtype int

type State

type State int

type Status

type Status int

Jump to

Keyboard shortcuts

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