Skip to main content

Player

Struct Player 

Source
pub struct Player {
    pub info: Info,
    pub finished_tracks: Arc<Mutex<Vec<i32>>>,
    pub ts: Arc<Mutex<f64>>,
    /* private fields */
}
Expand description

Primary playback controller.

Player owns the playback threads, buffering state, and runtime settings such as volume and reverb configuration.

Fields§

§info: Info§finished_tracks: Arc<Mutex<Vec<i32>>>§ts: Arc<Mutex<f64>>

Implementations§

Source§

impl Player

Source

pub fn new(file_path: &String) -> Self

Create a new player for a single container path.

Source

pub fn new_from_file_paths(file_paths: &Vec<Vec<String>>) -> Self

Create a new player for a set of standalone file paths.

Source

pub fn new_from_path_or_paths( path: Option<&String>, paths: Option<&Vec<Vec<String>>>, ) -> Self

Create a player from either a container path or standalone file paths.

Source

pub fn set_impulse_response_spec(&mut self, spec: ImpulseResponseSpec)

Override the impulse response used for convolution reverb.

Source

pub fn set_impulse_response_from_string(&mut self, value: &str)

Parse and apply an impulse response spec string.

Source

pub fn set_impulse_response_tail_db(&mut self, tail_db: f32)

Override the impulse response tail trim (dB).

Source

pub fn set_reverb_enabled(&self, enabled: bool)

Enable or disable convolution reverb.

Source

pub fn set_reverb_mix(&self, dry_wet: f32)

Set the reverb wet/dry mix (clamped to [0.0, 1.0]).

Source

pub fn get_reverb_settings(&self) -> ReverbSettings

Retrieve the current reverb settings snapshot.

Source

pub fn get_reverb_metrics(&self) -> ReverbMetrics

Retrieve the latest reverb performance metrics.

Source

pub fn debug_playback_state(&self) -> (bool, PlayerState, bool)

Debug helper returning thread alive, state, and audio heard flags.

Source

pub fn debug_buffering_done(&self) -> bool

Debug helper indicating whether buffering has completed.

Source

pub fn debug_timing_ms(&self) -> (u64, u64)

Debug helper returning internal timing markers in milliseconds.

Source

pub fn debug_sink_state(&self) -> (bool, bool, usize)

Debug helper returning sink paused/empty flags and queued length.

Source

pub fn set_start_buffer_ms(&self, start_buffer_ms: f32)

Configure the minimum buffered audio (ms) before playback starts.

Source

pub fn set_track_eos_ms(&self, track_eos_ms: f32)

Configure heuristic end-of-track threshold for containers (ms).

Source

pub fn play_at(&mut self, ts: f64)

Start playback from a specific timestamp (seconds).

Source

pub fn play(&mut self)

Start playback from the current timestamp.

Source

pub fn pause(&self)

Pause playback.

Source

pub fn resume(&self)

Resume playback if paused.

Source

pub fn kill_current(&self)

Stop the current playback thread without changing state.

Source

pub fn stop(&self)

Stop playback and reset timing state.

Source

pub fn is_playing(&self) -> bool

Return true if playback is currently active.

Source

pub fn is_paused(&self) -> bool

Return true if playback is currently paused.

Source

pub fn get_time(&self) -> f64

Get the current playback time in seconds.

Source

pub fn is_finished(&self) -> bool

Return true if playback has reached the end.

Source

pub fn sleep_until_end(&self)

Block the current thread until playback finishes.

Source

pub fn get_duration(&self) -> f64

Get the total duration (seconds) of the active selection.

Source

pub fn seek(&mut self, ts: f64)

Seek to the given timestamp (seconds).

Source

pub fn refresh_tracks(&mut self)

Refresh active track selections from the underlying container.

Source

pub fn shuffle(&mut self)

Shuffle track selections and restart playback.

Source

pub fn set_volume(&mut self, new_volume: f32)

Set the playback volume (0.0-1.0).

Source

pub fn get_volume(&self) -> f32

Get the current playback volume.

Source

pub fn get_ids(&self) -> Vec<String>

Get the track identifiers used for display.

Source

pub fn set_reporting( &mut self, reporting: Arc<Mutex<dyn Fn(Report) + Send>>, reporting_interval: Duration, )

Enable periodic reporting of playback status for UI consumers.

Trait Implementations§

Source§

impl Clone for Player

Source§

fn clone(&self) -> Player

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

Auto Trait Implementations§

§

impl Freeze for Player

§

impl RefUnwindSafe for Player

§

impl Send for Player

§

impl Sync for Player

§

impl Unpin for Player

§

impl UnwindSafe for Player

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.

Source§

impl<S> FromSample<S> for S

Source§

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.

Source§

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

Source§

fn into_sample(self) -> T

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
Source§

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

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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