player

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotConnected = errors.New("player not connected")
View Source
var ErrQueueEmpty = errors.New("queue is empty")

Functions

This section is empty.

Types

type ErrorHandler

type ErrorHandler func(err error)

type Firestore

type Firestore interface {
	UpsertSongIncPlaybacks(ctx context.Context, new *pkg.Song) (int, error)
	IncrementUserRequests(ctx context.Context, song *pkg.Song, userID string)
	GetRandomSongs(ctx context.Context, n int) ([]*pkg.Song, error)
}

type MediaPlayer

type MediaPlayer interface {
	Process(requests <-chan *audio.SongRequest) <-chan error
	Stats() pkg.SessionStats
	IsPlaying() bool
	Stop()
}

type MockPlayer

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

func (*MockPlayer) LoopStatus

func (m *MockPlayer) LoopStatus() bool

func (*MockPlayer) NowPlaying

func (m *MockPlayer) NowPlaying() *pkg.Song

func (*MockPlayer) Play

func (m *MockPlayer) Play(ctx context.Context, query, userID, guildID, channelID string) (*pkg.Song, error)

func (*MockPlayer) RadioStatus

func (m *MockPlayer) RadioStatus() bool

func (*MockPlayer) SetLoop

func (m *MockPlayer) SetLoop(ctx context.Context, b bool)

func (*MockPlayer) SetRadio

func (m *MockPlayer) SetRadio(ctx context.Context, b bool, guildID, channelID string) error

func (*MockPlayer) Skip

func (m *MockPlayer) Skip(ctx context.Context)

func (*MockPlayer) SongStatus

func (m *MockPlayer) SongStatus() pkg.SessionStats

func (*MockPlayer) Status

func (m *MockPlayer) Status() pkg.PlayerStatus

type Player

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

Player all public methods are concurrent and most private methods are designed to be synchronous

func NewPlayer

func NewPlayer(ctx context.Context, voice VoiceClient, audio MediaPlayer) *Player

func (*Player) Connect

func (p *Player) Connect(ctx context.Context, guildID, channelID string)

func (*Player) Disconnect

func (p *Player) Disconnect(ctx context.Context)

func (*Player) LoopStatus

func (p *Player) LoopStatus() bool

func (*Player) NowPlaying

func (p *Player) NowPlaying() *pkg.Song

func (*Player) Play

func (p *Player) Play(ctx context.Context, s *pkg.Song)

Play next song and enqueue input

func (*Player) SetLoop

func (p *Player) SetLoop(ctx context.Context, b bool)

func (*Player) Skip

func (p *Player) Skip(ctx context.Context)

func (*Player) SongStatus

func (p *Player) SongStatus() pkg.SessionStats

func (*Player) Stop

func (p *Player) Stop(ctx context.Context)

func (*Player) SubscribeOnErrors

func (p *Player) SubscribeOnErrors(h ErrorHandler)

type Queue

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

func (*Queue) Add

func (q *Queue) Add(e *pkg.Song)

func (*Queue) Clear

func (q *Queue) Clear()

func (*Queue) Front

func (q *Queue) Front() *pkg.Song

func (*Queue) IsEmpty

func (q *Queue) IsEmpty() bool

func (*Queue) LoopStatus

func (q *Queue) LoopStatus() bool

func (*Queue) Next

func (q *Queue) Next() *pkg.Song

func (*Queue) SetLoop

func (q *Queue) SetLoop(b bool)

type Service

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

func NewMusicService

func NewMusicService(ctx context.Context, storage Firestore, youtube YouTube, voice VoiceClient, audio MediaPlayer) *Service

func (*Service) Disconnect

func (s *Service) Disconnect(ctx context.Context)

func (*Service) Play

func (s *Service) Play(ctx context.Context, query, userID, guildID, channelID string) (*pkg.Song, error)

func (*Service) RadioStatus

func (s *Service) RadioStatus() bool

func (*Service) Random

func (s *Service) Random(ctx context.Context, n int) ([]*pkg.Song, error)

func (*Service) SetRadio

func (s *Service) SetRadio(ctx context.Context, b bool, guildID, channelID string) error

func (*Service) Status

func (s *Service) Status() pkg.PlayerStatus

func (*Service) Stop

func (s *Service) Stop(ctx context.Context)

func (*Service) SubscribeOnErrors

func (s *Service) SubscribeOnErrors(h ErrorHandler)

type VoiceClient

type VoiceClient interface {
	Connection() *discordgo.VoiceConnection
	Connect(guildID, channelID string) error
	IsConnected() bool
	Disconnect() error
}

type YouTube

type YouTube interface {
	FindSong(ctx context.Context, query string) (*pkg.Song, error)
	EnsureStreamInfo(ctx context.Context, song *pkg.Song) (*pkg.Song, error)
}

Jump to

Keyboard shortcuts

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