Documentation
¶
Overview ¶
Package player provides audio playback management.
Index ¶
- Variables
- type IPlayer
- type PlaybackStatus
- type Player
- func (p *Player) ClearQueue()
- func (p *Player) Dequeue() (*Song, error)
- func (p *Player) Enqueue(song *Song)
- func (p *Player) GetCurrentSong() *Song
- func (p *Player) GetCurrentStatus() PlaybackStatus
- func (p *Player) GetSongQueue() []*Song
- func (p *Player) GetStreamingSession() *dca.StreamingSession
- func (p *Player) GetVoiceConnection() *discordgo.VoiceConnection
- func (p *Player) Pause()
- func (p *Player) Play(startAt int, song *Song)
- func (p *Player) SetCurrentStatus(status PlaybackStatus)
- func (p *Player) SetVoiceConnection(voiceConnection *discordgo.VoiceConnection)
- func (p *Player) Skip()
- func (p *Player) Stop()
- func (p *Player) Unpause()
- type Song
- type SongSource
- type Thumbnail
Constants ¶
This section is empty.
Variables ¶
var ErrQueueEmpty = errors.New("queue is empty")
Functions ¶
This section is empty.
Types ¶
type IPlayer ¶
type IPlayer interface { Play(startAt int, song *Song) Skip() Enqueue(song *Song) Dequeue() (*Song, error) ClearQueue() Stop() Pause() Unpause() GetCurrentStatus() PlaybackStatus SetCurrentStatus(status PlaybackStatus) GetSongQueue() []*Song GetVoiceConnection() *discordgo.VoiceConnection SetVoiceConnection(voiceConnection *discordgo.VoiceConnection) GetStreamingSession() *dca.StreamingSession GetCurrentSong() *Song }
IPlayer defines the interface for managing audio playback and song queue.
type PlaybackStatus ¶
type PlaybackStatus int32
PlaybackStatus represents the playback status of the Player.
const ( StatusResting PlaybackStatus = iota StatusPlaying StatusPaused StatusError )
func (PlaybackStatus) String ¶
func (status PlaybackStatus) String() string
String returns the string representation of the PlaybackStatus.
func (PlaybackStatus) StringEmoji ¶
func (status PlaybackStatus) StringEmoji() string
type Player ¶
type Player struct { sync.Mutex VoiceConnection *discordgo.VoiceConnection StreamingSession *dca.StreamingSession EncodingSession *dca.EncodeSession SongQueue []*Song CurrentSong *Song CurrentStatus PlaybackStatus SkipInterrupt chan bool }
Player manages audio playback and song queue.
func (*Player) GetCurrentSong ¶
GetCurrentSong returns the current song being played.
func (*Player) GetCurrentStatus ¶
func (p *Player) GetCurrentStatus() PlaybackStatus
GetStatus returns the current playback status.
func (*Player) GetSongQueue ¶
GetSongQueue returns the song queue.
func (*Player) GetStreamingSession ¶
func (p *Player) GetStreamingSession() *dca.StreamingSession
GetStreamingSession returns the current streaming session.
func (*Player) GetVoiceConnection ¶
func (p *Player) GetVoiceConnection() *discordgo.VoiceConnection
GetVoiceConnection returns the voice connection.
func (*Player) SetCurrentStatus ¶
func (p *Player) SetCurrentStatus(status PlaybackStatus)
SetStatus sets the playback status.
func (*Player) SetVoiceConnection ¶
func (p *Player) SetVoiceConnection(voiceConnection *discordgo.VoiceConnection)
SetVoiceConnection sets the voice connection.
type Song ¶
type Song struct { Title string // Title of the song UserURL string // URL provided by the user DownloadURL string // URL for downloading the song Thumbnail Thumbnail // Thumbnail image for the song Duration time.Duration // Duration of the song ID string // Unique ID for the song Source SongSource // Source type of the song }
Song represents a media item with relevant information.
type SongSource ¶
type SongSource int32
SongSource represents the source type of the media.
const ( SourceYouTube SongSource = iota SourceStream )
func (SongSource) String ¶
func (source SongSource) String() string
String returns the string representation of the SongSource.