pub struct SharedPlayerState { /* private fields */ }Expand description
Shared player state — atomics for lock-free reads from UI thread.
The engine writes these, the UI reads them. No mutexes in the hot path.
Implementations§
pub fn new() -> Arc<Self>
pub fn playback_state(&self) -> PlaybackState
pub fn set_playback_state(&self, state: PlaybackState)
pub fn position_ms(&self) -> u64
pub fn set_position_ms(&self, pos: u64)
pub fn track_info(&self) -> Option<TrackInfo>
pub fn set_track_info(&self, info: Option<TrackInfo>)
Sourcepub fn current_download_fraction(&self) -> Option<f64>
pub fn current_download_fraction(&self) -> Option<f64>
Download fraction (0.0..1.0) for the currently playing track, if streaming.
Returns None for fully-downloaded or non-playing tracks.
pub fn bump_generation(&self) -> u64
pub fn generation(&self) -> u64
pub fn request_quit(&self)
pub fn quit_requested(&self) -> bool
Sourcepub fn signal_metadata_refresh(&self)
pub fn signal_metadata_refresh(&self)
Signal that metadata has been refreshed mid-stream (e.g. download completed).
The UI loop calls take_metadata_refresh() to consume this flag and
force a souvlaki/cover-art update without waiting for a track change.
Sourcepub fn take_metadata_refresh(&self) -> bool
pub fn take_metadata_refresh(&self) -> bool
Returns true and clears the flag if a metadata refresh is pending.
pub fn radio_mode(&self) -> bool
pub fn set_radio_mode(&self, enabled: bool)
pub fn playlist_version(&self) -> u64
Sourcepub fn add_items(&self, items: Vec<PlaylistItem>)
pub fn add_items(&self, items: Vec<PlaylistItem>)
Append items to the playlist.
Sourcepub fn insert_items_after(&self, items: Vec<PlaylistItem>, after: QueueItemId)
pub fn insert_items_after(&self, items: Vec<PlaylistItem>, after: QueueItemId)
Insert items after a specific queue item.
Sourcepub fn update_paths(&self, updates: &[(QueueItemId, PathBuf)])
pub fn update_paths(&self, updates: &[(QueueItemId, PathBuf)])
Update file paths for playlist items (after organize moves files).
Sourcepub fn remove_item(&self, id: QueueItemId)
pub fn remove_item(&self, id: QueueItemId)
Remove an item by ID.
Sourcepub fn move_item(&self, id: QueueItemId, target: QueueItemId, after: bool)
pub fn move_item(&self, id: QueueItemId, target: QueueItemId, after: bool)
Move an item relative to another entry.
Sourcepub fn move_items(&self, ids: &[QueueItemId], target: QueueItemId, after: bool)
pub fn move_items(&self, ids: &[QueueItemId], target: QueueItemId, after: bool)
Batch move: extract items by ID, reinsert them at target position.
Preserves the relative order of the moved items.
Sourcepub fn set_cursor(&self, id: Option<QueueItemId>)
pub fn set_cursor(&self, id: Option<QueueItemId>)
Set the cursor (what’s playing / should play).
Sourcepub fn cursor(&self) -> Option<QueueItemId>
pub fn cursor(&self) -> Option<QueueItemId>
Get the current cursor ID.
Sourcepub fn clear_playlist(&self)
pub fn clear_playlist(&self)
Clear the entire playlist + cursor.
Sourcepub fn advance_cursor(&self) -> Option<(QueueItemId, PathBuf)>
pub fn advance_cursor(&self) -> Option<(QueueItemId, PathBuf)>
Advance cursor to the next Ready item. Returns (id, path) if found. Moves the cursor. Used for explicit next-track commands.
Sourcepub fn peek_next_ready_after(
&self,
after_id: QueueItemId,
) -> Option<(QueueItemId, PathBuf)>
pub fn peek_next_ready_after( &self, after_id: QueueItemId, ) -> Option<(QueueItemId, PathBuf)>
Peek at the next Ready item after a given item ID WITHOUT moving the cursor. Used by the decode thread for gapless lookahead — the cursor is moved later by update_playback_state when playback actually reaches the track.
Sourcepub fn retreat_cursor(&self) -> Option<(QueueItemId, PathBuf)>
pub fn retreat_cursor(&self) -> Option<(QueueItemId, PathBuf)>
Retreat cursor to the previous item. Returns (id, path) if found. For prev_track — goes to the item before cursor regardless of load state.
Sourcepub fn update_load_state(&self, id: QueueItemId, new_state: LoadState)
pub fn update_load_state(&self, id: QueueItemId, new_state: LoadState)
Update the load state of a playlist item. Safe — just a field update under lock.
Sourcepub fn update_item_metadata(
&self,
id: QueueItemId,
title: String,
artist: String,
album_artist: String,
album: String,
duration_ms: Option<u64>,
)
pub fn update_item_metadata( &self, id: QueueItemId, title: String, artist: String, album_artist: String, album: String, duration_ms: Option<u64>, )
Update playlist item metadata after a full download completes. Used for progressive enhancement: streaming started with partial Symphonia tags, now the full file is available so we can refresh with complete lofty metadata.
Sourcepub fn item_playback_source(&self, id: QueueItemId) -> Option<PlaybackSource>
pub fn item_playback_source(&self, id: QueueItemId) -> Option<PlaybackSource>
Get the playback source for an item if it’s ready to play.
Returns None if not enough data is available yet.
Sourcepub fn item_path_if_ready(&self, id: QueueItemId) -> Option<PathBuf>
pub fn item_path_if_ready(&self, id: QueueItemId) -> Option<PathBuf>
Get the path of an item if it’s Ready (legacy convenience — use item_playback_source for streaming).
Sourcepub fn is_cursor(&self, id: QueueItemId) -> bool
pub fn is_cursor(&self, id: QueueItemId) -> bool
Check if the cursor is on the given item.
Sourcepub fn snapshot_playlist(&self) -> (Vec<PlaylistItem>, Option<QueueItemId>)
pub fn snapshot_playlist(&self) -> (Vec<PlaylistItem>, Option<QueueItemId>)
Get the full playlist snapshot (items + cursor) for undo of ClearPlaylist.
Sourcepub fn get_item(&self, id: QueueItemId) -> Option<PlaylistItem>
pub fn get_item(&self, id: QueueItemId) -> Option<PlaylistItem>
Get an item by ID (for undo of RemoveFromPlaylist).
Sourcepub fn item_before(&self, id: QueueItemId) -> Option<QueueItemId>
pub fn item_before(&self, id: QueueItemId) -> Option<QueueItemId>
Get the ID of the item immediately before the given ID (None if first).
Sourcepub fn items_before(
&self,
ids: &[QueueItemId],
) -> Vec<(QueueItemId, Option<QueueItemId>)>
pub fn items_before( &self, ids: &[QueueItemId], ) -> Vec<(QueueItemId, Option<QueueItemId>)>
For each ID, get the ID of the item before it (or None if first). Used to snapshot positions before a batch move for undo.
Sourcepub fn restore_playlist(
&self,
items: Vec<PlaylistItem>,
cursor: Option<QueueItemId>,
)
pub fn restore_playlist( &self, items: Vec<PlaylistItem>, cursor: Option<QueueItemId>, )
Restore a full playlist from snapshot (for redo of ClearPlaylist undo).
Sourcepub fn remove_items(&self, ids: &[QueueItemId])
pub fn remove_items(&self, ids: &[QueueItemId])
Remove multiple items by IDs.
Sourcepub fn insert_item_at(&self, item: PlaylistItem, after: Option<QueueItemId>)
pub fn insert_item_at(&self, item: PlaylistItem, after: Option<QueueItemId>)
Insert a single item after a given ID (or at front if None).
Sourcepub fn move_item_to(&self, id: QueueItemId, after: Option<QueueItemId>)
pub fn move_item_to(&self, id: QueueItemId, after: Option<QueueItemId>)
Move a single item to after after (or to front if None).
Sourcepub fn move_items_to(&self, entries: &[(QueueItemId, Option<QueueItemId>)])
pub fn move_items_to(&self, entries: &[(QueueItemId, Option<QueueItemId>)])
Batch move: reposition each item to after its given predecessor. Processes in order so earlier insertions don’t corrupt later positions.
Sourcepub fn derive_visible_queue(&self) -> VisibleQueueSnapshot
pub fn derive_visible_queue(&self) -> VisibleQueueSnapshot
Derive the visible queue from the playlist + cursor. O(n). Called once per UI tick.
Trait Implementations§
Auto Trait Implementations§
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
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 more