queue

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

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

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 New

func New() *Queue

New returns an empty queue.

func (*Queue) AdvanceAuto

func (q *Queue) AdvanceAuto() bool

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

func (q *Queue) AdvanceLinear() bool

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) Append

func (q *Queue) Append(tracks ...deezer.Track)

Append adds tracks to the end without moving the cursor.

func (*Queue) Current

func (q *Queue) Current() (deezer.Track, bool)

Current returns the current track and whether one exists.

func (*Queue) CycleRepeat

func (q *Queue) CycleRepeat() Repeat

func (*Queue) Index

func (q *Queue) Index() int

Index returns the current cursor (−1 if empty).

func (*Queue) Len

func (q *Queue) Len() int

Len reports the number of queued tracks.

func (*Queue) Next

func (q *Queue) Next() bool

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

func (q *Queue) PeekNext() (deezer.Track, bool)

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) Prev

func (q *Queue) Prev() bool

Prev steps back, retracing shuffle history when present.

func (*Queue) Repeat

func (q *Queue) Repeat() Repeat

func (*Queue) Set

func (q *Queue) Set(tracks []deezer.Track, start int)

Set replaces the queue contents and positions the cursor at start (clamped). History is cleared.

func (*Queue) SetIndex

func (q *Queue) SetIndex(i int)

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.

func (*Queue) SetRepeat

func (q *Queue) SetRepeat(r Repeat)

func (*Queue) SetShuffle

func (q *Queue) SetShuffle(on bool)

func (*Queue) Shuffle

func (q *Queue) Shuffle() bool

Shuffle / Repeat accessors.

func (*Queue) ToggleShuffle

func (q *Queue) ToggleShuffle() bool

func (*Queue) Tracks

func (q *Queue) Tracks() []deezer.Track

Tracks returns the underlying slice (read-only; do not mutate).

type Repeat

type Repeat int

Repeat is the loop mode.

const (
	RepeatOff Repeat = iota
	RepeatAll
	RepeatOne
)

func (Repeat) String

func (r Repeat) String() string

Jump to

Keyboard shortcuts

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