Documentation
¶
Overview ¶
Package queue is the playback queue model shared by the TUI and the C API (via corelib), so shuffle/repeat/prev-history behaviour is defined once instead of being re-implemented per frontend.
Index ¶
- type Queue
- func (q *Queue) AdvanceAuto() bool
- func (q *Queue) AdvanceLinear() bool
- func (q *Queue) Append(tracks ...deezer.Track)
- func (q *Queue) Current() (deezer.Track, bool)
- func (q *Queue) CycleRepeat() Repeat
- func (q *Queue) Index() int
- func (q *Queue) Len() int
- func (q *Queue) Next() bool
- func (q *Queue) PeekNext() (deezer.Track, bool)
- func (q *Queue) Prev() bool
- func (q *Queue) Repeat() Repeat
- func (q *Queue) Set(tracks []deezer.Track, start int)
- func (q *Queue) SetIndex(i int)
- func (q *Queue) SetRepeat(r Repeat)
- func (q *Queue) SetShuffle(on bool)
- func (q *Queue) Shuffle() bool
- func (q *Queue) ToggleShuffle() bool
- func (q *Queue) Tracks() []deezer.Track
- type Repeat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue holds an ordered track list plus a cursor, shuffle/repeat state and a visited-index history (so Prev under shuffle retraces the real path). The zero value is a valid empty queue. Not safe for concurrent use; callers serialize.
func (*Queue) AdvanceAuto ¶
AdvanceAuto is called when a track ends naturally: RepeatOne replays the current track (reports true, cursor unchanged); otherwise it behaves like Next. Returns whether playback should continue.
func (*Queue) AdvanceLinear ¶ added in v1.6.0
AdvanceLinear advances the cursor to the deterministic next track (linear +1, or a RepeatAll wrap) regardless of shuffle/RepeatOne, matching exactly what PeekNext returned. Used to sync the cursor after the player gaplessly swapped in the preloaded (always deterministic) next track, so the cursor can't jump to a random shuffle pick that differs from the audio. Reports whether it moved.
func (*Queue) CycleRepeat ¶
func (*Queue) Next ¶
Next advances the cursor following shuffle/repeat rules and reports whether it moved to a playable track. RepeatOne is treated as a normal advance here (the caller decides whether a natural finish should instead replay current — see AdvanceAuto).
func (*Queue) PeekNext ¶ added in v0.4.0
PeekNext returns the track Next would advance to, WITHOUT mutating the queue, for the deterministic cases only (linear order, with RepeatAll wrap). Under shuffle or RepeatOne it returns ok=false, since the next track isn't fixed — callers use this to decide whether a gapless preload is safe.
func (*Queue) Set ¶
Set replaces the queue contents and positions the cursor at start (clamped). History is cleared.
func (*Queue) SetIndex ¶
SetIndex moves the cursor (clamped); use when the user picks a row directly. The previous position is recorded so Prev retraces to the track that was actually playing before the pick.