Struct Queue

Source
pub struct Queue { /* private fields */ }
Expand description

A selection with a cursor and a deterministic playing order.

Implementations§

Source§

impl Queue

Source

pub fn new(tracks: Vec<Id>, seed: Option<u64>) -> Self

Build from the same ordered track IDs used by playlist rendering.

seed = None keeps the selection order. A seed shuffles it with a fixed algorithm, independently of platform or process state.

Source

pub fn selection(&self) -> &[Id] ⓘ

The original selection, including duplicate entries.

Source

pub fn ordered_tracks(&self) -> impl Iterator<Item = Id> + '_

IDs in their current playing order.

Source

pub fn seed(&self) -> Option<u64>

The shuffle seed, if the queue is shuffled.

Source

pub fn current(&self) -> Option<Id>

The currently selected track.

Source

pub fn cursor(&self) -> Option<usize>

The cursor in the current playing order.

Source

pub fn current_entry(&self) -> Option<usize>

Original selection occurrence under the cursor, distinguishing repeats.

Source

pub fn select_entry(&mut self, entry: usize) -> bool

Select an existing occurrence after the driver abandons preparation of a later source. Missing occurrences leave the queue unchanged.

Source

pub fn order(&self) -> &[usize]

The current permutation of original selection occurrences.

Source

pub fn reorder( &mut self, order: Vec<usize>, seed: Option<u64>, ) -> Result<(), &'static str>

Replace future order, retaining the played prefix and current occurrence.

order must contain every original occurrence exactly once. Invalid input leaves transport, history, seed and position unchanged. Changing mode clears saved neighbouring cycles, but not Previous within this one.

Source

pub fn set_next_order( &mut self, order: Vec<usize>, seed: Option<u64>, ) -> Result<bool, &'static str>

Supply an externally planned next repeat-all cycle.

Return false when Previous has already retained the forward cycle. Such an order must not be silently replaced by a new shuffle draw.

Source

pub fn next_seed(&self) -> Option<u64>

Reproducible seed for the next shuffled repeat-all cycle.

Source

pub fn transport(&self) -> Transport

Current transport state.

Source

pub fn position_ms(&self) -> u64

Position in the current track, supplied by the playback driver.

Source

pub fn set_position_ms(&mut self, position_ms: u64) -> bool

Update the observed position after a successful playback or seek. An empty queue cannot acquire a position.

Source

pub fn set_repeat(&mut self, repeat: Repeat)

Change how natural ends are handled.

Source

pub fn repeat(&self) -> Repeat

The active repeat mode.

Source

pub fn play(&mut self) -> Option<Id>

Start or resume the selected track; select the first entry if needed.

Source

pub fn pause(&mut self)

Pause only while playing.

Source

pub fn stop(&mut self)

Stop sound and return the selected track to its start.

Source

pub fn skip_next(&mut self) -> Option<Id>

Skip to the next entry, even with repeat-one enabled. Keeps the current playing or paused state until the queue is exhausted.

Source

pub fn finished(&mut self) -> Option<Id>

Advance after natural end; repeat-one restarts the current entry.

Source

pub fn previous(&mut self) -> Option<Id>

Restart the current track after three seconds; otherwise step back. At the beginning of the current playing order, restart its first entry.

Trait Implementations§

Source§

impl Clone for Queue

Source§

fn clone(&self) -> Queue

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Queue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Queue

§

impl RefUnwindSafe for Queue

§

impl Send for Queue

§

impl Sync for Queue

§

impl Unpin for Queue

§

impl UnwindSafe for Queue

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,