Struct playdate::sound::player::FilePlayer

source ·
pub struct FilePlayer<Api = Default>(/* private fields */)
where
    Api: Api;

Implementations§

source§

impl<Api> Player<Api>
where Api: Api,

source

pub fn new() -> Result<Player<Api>, Error>
where Api: Default,

source

pub fn new_with(api: Api) -> Result<Player<Api>, Error>

source§

impl<Api> Player<Api>
where Api: Api,

source

pub fn api(&self) -> &Api

source§

impl<Api> Player<Api>
where Api: Api,

source

pub fn load_into_player<P>(&self, path: P) -> Result<(), Error<Error>>
where P: AsRef<str>,

Prepares player to stream the file at path.

Equivalent to loadIntoPlayer

source

pub fn set_buffer_length(&self, len: f32)

Sets the buffer length of player to len seconds.

Equivalent to setBufferLength

source

pub fn is_playing(&self) -> bool

Returns true if player is playing.

Equivalent to isPlaying

source

pub fn play(&self, repeat: Repeat) -> i32

Starts playing the file player.

Equivalent to play

source

pub fn stop(&self)

Stops playing the file.

Equivalent to stop

source

pub fn volume(&self) -> (f32, f32)

Gets the left and right channel playback volume for player.

Equivalent to getVolume

source

pub fn set_volume(&self, left: f32, right: f32)

Sets the playback volume for left and right channels of player.

Equivalent to setVolume

source

pub fn length(&self) -> f32

Returns the length, in seconds, of the file loaded into player.

Equivalent to getLength

source

pub fn offset(&self) -> f32

Gets the current offset in seconds for player.

Equivalent to getOffset

source

pub fn set_offset(&self, offset: f32)

Sets the current offset in seconds.

Equivalent to setOffset

source

pub fn rate(&self) -> f32

Gets the playback rate for player.

Equivalent to getRate

source

pub fn set_rate(&self, rate: f32)

Sets the playback rate for the player.

1.0 is normal speed, 0.5 is down an octave, 2.0 is up an octave, etc.

Unlike SamplePlayer, FilePlayers can’t play in reverse (i.e., rate < 0).

Equivalent to setRate

source

pub fn set_loop_range(&self, start: f32, end: f32)

Sets the start and end of the loop region for playback, in seconds.

If end is omitted, the end of the file is used.

Equivalent to setLoopRange

source

pub fn did_underrun(&self) -> bool

Returns true if player has underrun, false if not.

Equivalent to didUnderrun

source

pub fn set_stop_on_underrun(&self, value: bool)

If value is true, the player will restart playback (after an audible stutter) as soon as data is available.

Equivalent to setStopOnUnderrun

source

pub fn set_finish_callback( &self, callback: Option<unsafe extern "C" fn(_: *mut SoundSource, _: *mut c_void)> )

Sets a function to be called when playback has completed.

This is an alias for sys::ffi::playdate_sound_source::setFinishCallback.

Equivalent to setFinishCallback

source

pub fn set_loop_callback( &self, callback: Option<unsafe extern "C" fn(_: *mut SoundSource, _: *mut c_void)> )

Equivalent to setLoopCallback

source

pub fn fade_volume( &self, left: f32, right: f32, len: i32, finish_callback: Option<unsafe extern "C" fn(_: *mut SoundSource, _: *mut c_void)> )

Changes the volume of the Player to left and right over a length of len sample frames, then calls the provided callback (if set).

Equivalent to fadeVolume

source

pub fn set_mp3_stream_source( &self, source: Option<unsafe extern "C" fn(_: *mut u8, _: i32, _: *mut c_void) -> i32>, userdata: *mut c_void, buffer_len: f32 )

Equivalent to setMP3StreamSource

Trait Implementations§

source§

impl<Api> Debug for Player<Api>
where Api: Debug + Api,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<Api> Drop for Player<Api>
where Api: Api,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<Api> Freeze for Player<Api>
where Api: Freeze,

§

impl<Api> RefUnwindSafe for Player<Api>
where Api: RefUnwindSafe,

§

impl<Api = Default> !Send for Player<Api>

§

impl<Api = Default> !Sync for Player<Api>

§

impl<Api> Unpin for Player<Api>
where Api: Unpin,

§

impl<Api> UnwindSafe for Player<Api>
where Api: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.