Struct FilePlaybackOptions

Source
pub struct FilePlaybackOptions {
    pub stream: bool,
    pub volume: f32,
    pub panning: f32,
    pub speed: f64,
    pub repeat: usize,
    pub start_time: Option<u64>,
    pub fade_in_duration: Option<Duration>,
    pub fade_out_duration: Option<Duration>,
    pub resampling_quality: ResamplingQuality,
    pub playback_pos_emit_rate: Option<Duration>,
}
Expand description

Options to control playback of a FileSource.

Fields§

§stream: bool

By default false: when true, the file will be decoded and streamed on the fly. This should be enabled for very long files only, especiall when a lot of files are going to be played at once.

§volume: f32

By default 1.0f32. Customize to lower or raise the volume of the file.

§panning: f32

By default 0.0f32. Set in range -1.0..=1.0 to adjust panning position.

§speed: f64

By default 1.0f64. Customize to pitch the playback speed up or down. See also resampling_quality property.

§repeat: usize

By default 0: when > 0 the number of times the file should be looped. Set to usize::MAX to repeat forever.

§start_time: Option<u64>

By default None: when set, the source should start playing at the given sample frame time in the audio output stream.

§fade_in_duration: Option<Duration>

By default None: when set, the source’s volume will fade in with the given amount when starting to play.

§fade_out_duration: Option<Duration>

By default 5ms: volume fade out duration, applied when the the source gets stopped before it finished playing.

§resampling_quality: ResamplingQuality

By default ResamplingQuality::Default: Quality mode of a applied resampler, either when the source is getting played back on a stream with a sample rate which does not match the file’s sample rate or when pitching the playback up or down.

§playback_pos_emit_rate: Option<Duration>

Wallclock time rate of playback pos events, emited via PlaybackStatusEvent in the player. By default one second to avoid unnecessary overhead. Set to e.g. Duration::from_secf32(1.0/30.0) to trigger events 30 times per second.

Implementations§

Source§

impl FilePlaybackOptions

Source

pub fn preloaded(self) -> Self

Source

pub fn streamed(self) -> Self

Source

pub fn volume(self, volume: f32) -> Self

Source

pub fn volume_db(self, volume_db: f32) -> Self

Source

pub fn panning(self, panning: f32) -> Self

Source

pub fn fade_in(self, duration: Duration) -> Self

Source

pub fn fade_out(self, duration: Duration) -> Self

Source

pub fn speed(self, speed: f64) -> Self

Source

pub fn repeat(self, count: usize) -> Self

Source

pub fn repeat_forever(self) -> Self

Source

pub fn start_at_time(self, sample_time: u64) -> Self

Source

pub fn playback_pos_emit_rate(self, duration: Duration) -> Self

Source

pub fn resampling_quality(self, quality: ResamplingQuality) -> Self

Source

pub fn validate(&self) -> Result<(), Error>

Validate all parameters. Returns Error::ParameterError on errors.

Trait Implementations§

Source§

impl Clone for FilePlaybackOptions

Source§

fn clone(&self) -> FilePlaybackOptions

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

impl Default for FilePlaybackOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Copy for FilePlaybackOptions

Auto Trait Implementations§

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,