pub struct Player { /* private fields */ }Expand description
Audio playback engine with queue and controls
Implementations§
Source§impl Player
impl Player
Sourcepub async fn new(client: Arc<MonoClient>) -> Arc<Self>
pub async fn new(client: Arc<MonoClient>) -> Arc<Self>
Create a new Player. Spawns a dedicated audio thread and background watchers.
Sourcepub async fn play_track(&self, id: u64, quality: &str) -> Result<(), String>
pub async fn play_track(&self, id: u64, quality: &str) -> Result<(), String>
Play a track immediately, stopping whatever is currently playing.
Sourcepub async fn previous(&self) -> Result<(), String>
pub async fn previous(&self) -> Result<(), String>
Go to previous track (from history), or restart current if >5s in
Sourcepub async fn set_volume(&self, level: f32)
pub async fn set_volume(&self, level: f32)
Set volume (0.0–1.0)
Sourcepub async fn set_preamp(&self, level: f32)
pub async fn set_preamp(&self, level: f32)
Set pre-amp gain (0.0–4.0, where >1.0 boosts)
Sourcepub async fn queue_add(&self, id: u64, quality: &str) -> Result<(), String>
pub async fn queue_add(&self, id: u64, quality: &str) -> Result<(), String>
Add a track to the end of the queue. Auto-starts if idle.
Sourcepub async fn queue_album(
&self,
album_id: u64,
quality: &str,
) -> Result<Vec<QueuedTrack>, String>
pub async fn queue_album( &self, album_id: u64, quality: &str, ) -> Result<Vec<QueuedTrack>, String>
Add all tracks from an album to the queue. Auto-starts if idle.
Sourcepub async fn queue_batch(
&self,
ids: &[u64],
quality: &str,
) -> Result<Vec<QueuedTrack>, String>
pub async fn queue_batch( &self, ids: &[u64], quality: &str, ) -> Result<Vec<QueuedTrack>, String>
Add multiple tracks to the queue at once. Auto-starts if idle.
Sourcepub async fn queue_clear(&self)
pub async fn queue_clear(&self)
Clear the queue (does not stop current track)
Sourcepub async fn queue_get(&self) -> (Option<QueuedTrack>, Vec<QueuedTrack>)
pub async fn queue_get(&self) -> (Option<QueuedTrack>, Vec<QueuedTrack>)
Get current track and queue contents
Sourcepub async fn queue_reorder(&self, from: usize, to: usize) -> Result<(), String>
pub async fn queue_reorder(&self, from: usize, to: usize) -> Result<(), String>
Reorder a track in the queue
Sourcepub fn subscribe_now_playing(&self) -> Receiver<NowPlaying>
pub fn subscribe_now_playing(&self) -> Receiver<NowPlaying>
Subscribe to now-playing updates
Sourcepub async fn get_state(&self) -> PlayerState
pub async fn get_state(&self) -> PlayerState
Snapshot current state for persistence
Sourcepub async fn save_state(&self)
pub async fn save_state(&self)
Save current state to disk
Sourcepub async fn restore_state(&self)
pub async fn restore_state(&self)
Restore state from disk — resumes playback at the saved position
Auto Trait Implementations§
impl !Freeze for Player
impl !RefUnwindSafe for Player
impl Send for Player
impl Sync for Player
impl Unpin for Player
impl UnsafeUnpin for Player
impl !UnwindSafe 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
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<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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.