Documentation ¶
Index ¶
- Variables
- type Dj
- func (dj *Dj) AddEndOfSongHandler(f func(QueueEntry, error))
- func (dj *Dj) AddEntry(newEntry QueueEntry)
- func (dj *Dj) AddNewSongHandler(f func(QueueEntry))
- func (dj *Dj) AddPlaybackErrorHandler(f func(error))
- func (dj *Dj) ChangeIndex(newEntry QueueEntry, index int) error
- func (dj *Dj) CurrentlyPlaying() (entry QueueEntry, progress time.Duration, err error)
- func (dj *Dj) DurationUntilUser(nick string) (durations []time.Duration)
- func (dj *Dj) EntryAtIndex(index int) (QueueEntry, error)
- func (dj *Dj) InsertEntry(newEntry QueueEntry, index int) error
- func (dj *Dj) Play(rtmpServer string)
- func (dj *Dj) Queue() []QueueEntry
- func (dj *Dj) RemoveIndex(index int) error
- func (dj *Dj) UserPosition(nick string) (positions []int)
- type Media
- type QueueEntry
Constants ¶
This section is empty.
Variables ¶
var ErrorEmptyQueue = errors.New("can't pop from empty queue")
Functions ¶
This section is empty.
Types ¶
type Dj ¶
type Dj struct {
// contains filtered or unexported fields
}
Dj stores the queue and handlers
func (*Dj) AddEndOfSongHandler ¶
func (dj *Dj) AddEndOfSongHandler(f func(QueueEntry, error))
AddEndOfSongHandler adds a function that will be called every time a song stops playing. It gets passed the QueueEntry that finished playing and any errors encountered during playback.
func (*Dj) AddEntry ¶
func (dj *Dj) AddEntry(newEntry QueueEntry)
AddEntry adds the passed QueueEntry at the end of the queue.
func (*Dj) AddNewSongHandler ¶
func (dj *Dj) AddNewSongHandler(f func(QueueEntry))
AddNewSongHandler adds a function that will be called every time a new song starts playing.
func (*Dj) AddPlaybackErrorHandler ¶
AddPlaybackErrorHandler adds a function that will be called every time an error occurs during playback.
In effect this mean it will be called every time ffmpeg or yt-dlp exit with an error. Sometimes ffmpeg can exit with code 1 even though the song was streamed successfully.
func (*Dj) ChangeIndex ¶
func (dj *Dj) ChangeIndex(newEntry QueueEntry, index int) error
ChangeIndex swaps the QueueEntry the index for the provided one
returns an error if the index is out of range
func (*Dj) CurrentlyPlaying ¶
func (dj *Dj) CurrentlyPlaying() (entry QueueEntry, progress time.Duration, err error)
CurrentlyPlaying returns the song that is currently being played and for how long it has been playing.
Returns an error if there is nothing playing.
func (*Dj) DurationUntilUser ¶
DurationUntilUser returns a slice of all the durations to the songs in the queue that belong to the given user.
func (*Dj) EntryAtIndex ¶
func (dj *Dj) EntryAtIndex(index int) (QueueEntry, error)
EntryAtIndex returns the QueueEntry at the given index or error if the index is out of range
func (*Dj) InsertEntry ¶
func (dj *Dj) InsertEntry(newEntry QueueEntry, index int) error
InsertEntry inserts the passed QueueEntry into the queue at the given index.
if the index is too high it has the same effect as AddEntry(). returns an error if the index is < 0.
func (*Dj) Play ¶
Play starts the playback to the given RTMP server.
If nothing is in the playlist it waits for new content to be added. Any encoutered errors are handled by the errorHandler.
func (*Dj) Queue ¶
func (dj *Dj) Queue() []QueueEntry
Queue return the current queue as a list of queue entries.
func (*Dj) RemoveIndex ¶
RemoveIndex removes the element the given index from the queue
returns an error if the index is out of range.
func (*Dj) UserPosition ¶
UserPosition returns a slice of all the position in the queue that belong to the given user.
type Media ¶
Media represents a video or song that can be streamed.
this can be anything youtube-dl supports.
type QueueEntry ¶
A QueueEntry represents media and metadata the can be ented into a queue.