player

package
v0.0.0-...-2e53e79 Latest Latest
Warning

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

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

Documentation

Overview

TODO: если бот отключился, то кидать событие destroy TODO: stop downloader if skip current song +++ вынести загрузку в отедльный поток можно сделать такую же схему как и с аудио с workChan и если загрузка не началась, то скипать событие

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrDifferentVoiceChannel = fmt.Errorf("voice connected to a different voice channel")
	ErrNullVoiceChannelID = fmt.Errorf("null voice channel id")
)

Functions

func New

func New(ctx context.Context, playlist PlaylistManager, downloader Downloader, stateTick time.Duration) *service

Types

type AudioService

type AudioService interface {
	Play(ctx context.Context, source string, position time.Duration) bool
	Stop()
	Destroy()
	DestroyIdle() bool
	Idle() bool
	Finished() <-chan string
	SongPosition() <-chan audio.SongPosition
}

type Downloader

type Downloader interface {
	Download(ctx context.Context, request *psong.Item) (string, error)
	Delete(path string) error
}

type ErrorHandler

type ErrorHandler func(err error)

type PlaylistManager

type PlaylistManager interface {
	Head() *psong.Item
	Remove(force bool)
	Add(item *psong.Item)
	Current() *psong.Item
	Queue() []psong.Item

	Loop(state bool)
	LoopToggle() bool
	Radio(state bool)
	RadioToggle() bool
	Shuffle(state bool)
	ShuffleToggle() bool

	State() playlist.State
}

type State

type State struct {
	Current  *psong.Item   `json:"current"`
	Position time.Duration `json:"position"`
	Length   time.Duration `json:"length"`
	Loop     bool          `json:"loop"`
	Radio    bool          `json:"radio"`
	Shuffle  bool          `json:"shuffle"`
	Queue    []psong.Item  `json:"queue"`
}

type StateHandler

type StateHandler func(state State)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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