pub struct Player { /* private fields */ }Implementations§
Source§impl Player
impl Player
Sourcepub fn new(preferred_sampling_rates: Option<Vec<u32>>) -> Result<Player>
pub fn new(preferred_sampling_rates: Option<Vec<u32>>) -> Result<Player>
Creates a new Player to play Songs. If specified, the player will attempt to use one of the specified sampling rates. If not specified or the list is empty, the preferred rates are 48000 and 44100.
If none of the preferred sampling rates are available, the closest available rate to the first preferred rate will be selected.
On Linux, this prefers pipewire, jack, and pulseaudio devices over alsa.
Sourcepub fn set_playback_speed(&self, speed: f64)
pub fn set_playback_speed(&self, speed: f64)
Set the playback speed (This will also affect song pitch)
Sourcepub fn play_song_next(
&self,
song: &Song,
start_time: Option<Duration>,
) -> Result<()>
pub fn play_song_next( &self, song: &Song, start_time: Option<Duration>, ) -> Result<()>
Set the song that will play after the current song is over (or immediately if no song is currently playing), optionally start playing in the middle of the song.
Sourcepub fn play_song_now(
&self,
song: &Song,
start_time: Option<Duration>,
) -> Result<()>
pub fn play_song_now( &self, song: &Song, start_time: Option<Duration>, ) -> Result<()>
Start playing a song immediately, while discarding any song that might have been queued to play next. Optionally start playing in the middle of the song.
Sourcepub fn force_replace_next_song(
&self,
song: &Song,
start_time: Option<Duration>,
) -> Result<()>
pub fn force_replace_next_song( &self, song: &Song, start_time: Option<Duration>, ) -> Result<()>
Used to replace the next song, or the current song if there is no next song. Optionally start playing in the middle of the song.
This will remove the current song if no next song exists to avoid a race condition in case the current song ends after you have determined that the next song must be replaced but before you call this function.
See also force_remove_next_song
Sourcepub fn force_remove_next_song(&self) -> Result<()>
pub fn force_remove_next_song(&self) -> Result<()>
Used to remove the next song, or the current song if there is no next song.
This will remove the current song if no next song exists to avoid a race condition in case the current song ends after you have determined that the next song must be replaced but before you call this function.
See also force_replace_next_song
Sourcepub fn stop(&self)
pub fn stop(&self)
Stop playing any songs and remove a next song if it has been queued.
Note that this does not pause playback (use set_playing), meaning new songs will play upon adding them.
Sourcepub fn skip(&self)
pub fn skip(&self)
Skip the currently playing song (i.e. stop playing it immediately.
This will immediately start playing the next song if it exists.
Sourcepub fn get_playback_position(&self) -> Option<(Duration, Duration)>
pub fn get_playback_position(&self) -> Option<(Duration, Duration)>
Return the current playback position, if there is currently a song playing (see has_current_song)
See also seek
Sourcepub fn seek(&self, time: Duration) -> bool
pub fn seek(&self, time: Duration) -> bool
Set the current playback position if there is a song playing or a song queued to be played next.
Returns whether the seek was successful (whether there was a song to seek). Note that seeking past the end of the song will be successful and will cause playback to begin at the beginning of the next song.
See also get_playback_position
Sourcepub fn set_playing(&self, playing: bool)
pub fn set_playing(&self, playing: bool)
Sets whether playback is enabled or not, without touching the song queue.
See also is_playing
Sourcepub fn is_playing(&self) -> bool
pub fn is_playing(&self) -> bool
Returns whether playback is currently paused.
See also set_playing
Sourcepub fn has_next_song(&self) -> bool
pub fn has_next_song(&self) -> bool
Returns whether there is a song queued to play next after the current song has finished
If you want to check whether there is currently a song playing, use has_current_song and is_playing.
This should always be queried before calling play_song_next if you do not intend on replacing the song currently in the queue.
Sourcepub fn has_current_song(&self) -> bool
pub fn has_current_song(&self) -> bool
Returns whether there is a song currently playing (or about to start playing next audio frame)
Note that this does not indicate whether the current song is actively being played or paused, for that functionality you can use is_playing.
Sourcepub fn get_errors(&self) -> (Vec<Report>, u64)
pub fn get_errors(&self) -> (Vec<Report>, u64)
Returns a list of playback errors that have been collected and the total number of errors detected.
The library will only store 5 errors at a time and all others will be thrown away, so this function also returns a count of the errors up to this point.
Sourcepub fn reset_errors(&self) -> u64
pub fn reset_errors(&self) -> u64
Resets the playback error count and returns the old value.
This also has the effect of clearing out any errors that have been saved so that the library will only ever collect up to 5 errors.
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> 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<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more