pub struct Player { /* private fields */ }Expand description
The player controller. Owns the audio pipeline and processes commands.
Implementations§
Source§impl Player
impl Player
pub fn new() -> Self
Get a clone of the shared state for UI reads.
Sourcepub fn timeline(&self) -> Arc<PlaybackTimeline> ⓘ
pub fn timeline(&self) -> Arc<PlaybackTimeline> ⓘ
Get the playback timeline for UI reads.
Sourcepub fn viz_buffer(&self) -> Arc<VizBuffer> ⓘ
pub fn viz_buffer(&self) -> Arc<VizBuffer> ⓘ
Get the visualization buffer for the TUI.
Sourcepub fn viz_snapshot(&self) -> Arc<VizSnapshot> ⓘ
pub fn viz_snapshot(&self) -> Arc<VizSnapshot> ⓘ
Get the shared analysis snapshot for the TUI. The analysis thread writes here; the UI thread reads a clone each frame.
Sourcepub fn undo_stack(&self) -> &UndoStack
pub fn undo_stack(&self) -> &UndoStack
Access undo stack (for tests and UI state queries).
Sourcepub fn set_output_device(&mut self, name: String)
pub fn set_output_device(&mut self, name: String)
Switch the output device. Persists to config and restarts the engine on the current track if playing.
Sourcepub fn clear_output_device(&mut self)
pub fn clear_output_device(&mut self)
Clear the configured output device, reverting to system default.
Sourcepub fn output_device_name(&self) -> Option<&str>
pub fn output_device_name(&self) -> Option<&str>
Get the current output device name (if configured).
Sourcepub fn command_sender(&self) -> Sender<PlayerCommand>
pub fn command_sender(&self) -> Sender<PlayerCommand>
Get a command sender for the UI layer.
Sourcepub fn play(&mut self, id: QueueItemId)
pub fn play(&mut self, id: QueueItemId)
Play a specific item in the playlist by ID. Sets cursor, starts playback if Ready or streaming-ready, otherwise waits for TrackReady.
Sourcepub fn seek(&mut self, position_ms: u64)
pub fn seek(&mut self, position_ms: u64)
Seek within the current track. Clamps to just before the end to avoid accidentally skipping. Preserves pause state.
Sourcepub fn next_track(&mut self)
pub fn next_track(&mut self)
Skip to next track in playlist.
Sourcepub fn prev_track(&mut self)
pub fn prev_track(&mut self)
Go back to previous track.
Sourcepub fn remove_from_playlist(&mut self, id: QueueItemId)
pub fn remove_from_playlist(&mut self, id: QueueItemId)
Remove a track from the playlist. If it was the cursor, skip to next.
Sourcepub fn track_ready(&mut self, id: QueueItemId)
pub fn track_ready(&mut self, id: QueueItemId)
A download finished — if cursor is waiting on this item, start playback. If already streaming this item, trigger progressive metadata enhancement.
Sourcepub fn track_stream_ready(&mut self, id: QueueItemId)
pub fn track_stream_ready(&mut self, id: QueueItemId)
Called when enough data has been buffered for streaming playback. If the cursor is waiting on this track and nothing is playing, start streaming.
Sourcepub fn update_playback_state(&self)
pub fn update_playback_state(&self)
Poll the timeline and update shared state with current track/position. Called from the command loop on each tick.
Sourcepub fn process_command(&mut self, cmd: PlayerCommand)
pub fn process_command(&mut self, cmd: PlayerCommand)
Process a single command.
Sourcepub fn spawn() -> (Arc<SharedPlayerState>, Arc<PlaybackTimeline>, Arc<VizSnapshot>, Sender<PlayerCommand>)
pub fn spawn() -> (Arc<SharedPlayerState>, Arc<PlaybackTimeline>, Arc<VizSnapshot>, Sender<PlayerCommand>)
Spawn the player on a background thread, returning the shared state, timeline, visualization snapshot, and command sender.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Player
impl !Sync for Player
impl !UnwindSafe for Player
impl Freeze for Player
impl Send for Player
impl Unpin for Player
impl UnsafeUnpin for Player
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);