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,
impl<Api> Player<Api>where
Api: Api,
sourcepub fn load_into_player<P>(&self, path: P) -> Result<(), Error<Error>>where
P: AsRef<str>,
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
sourcepub fn set_buffer_length(&self, len: f32)
pub fn set_buffer_length(&self, len: f32)
Sets the buffer length of player to len
seconds.
Equivalent to setBufferLength
sourcepub fn is_playing(&self) -> bool
pub fn is_playing(&self) -> bool
Returns true
if player is playing.
Equivalent to isPlaying
sourcepub fn volume(&self) -> (f32, f32)
pub fn volume(&self) -> (f32, f32)
Gets the left and right channel playback volume for player.
Equivalent to getVolume
sourcepub fn set_volume(&self, left: f32, right: f32)
pub fn set_volume(&self, left: f32, right: f32)
Sets the playback volume for left and right channels of player.
Equivalent to setVolume
sourcepub fn length(&self) -> f32
pub fn length(&self) -> f32
Returns the length, in seconds, of the file loaded into player.
Equivalent to getLength
sourcepub fn offset(&self) -> f32
pub fn offset(&self) -> f32
Gets the current offset in seconds for player.
Equivalent to getOffset
sourcepub fn set_offset(&self, offset: f32)
pub fn set_offset(&self, offset: f32)
Sets the current offset in seconds.
Equivalent to setOffset
sourcepub fn set_rate(&self, rate: f32)
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
,
FilePlayer
s can’t play in reverse (i.e., rate < 0).
Equivalent to setRate
sourcepub fn set_loop_range(&self, start: f32, end: f32)
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
sourcepub fn did_underrun(&self) -> bool
pub fn did_underrun(&self) -> bool
Returns true
if player has underrun, false
if not.
Equivalent to didUnderrun
sourcepub fn set_stop_on_underrun(&self, value: bool)
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
sourcepub fn set_finish_callback(
&self,
callback: Option<unsafe extern "C" fn(_: *mut SoundSource, _: *mut c_void)>
)
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
sourcepub fn set_loop_callback(
&self,
callback: Option<unsafe extern "C" fn(_: *mut SoundSource, _: *mut c_void)>
)
pub fn set_loop_callback( &self, callback: Option<unsafe extern "C" fn(_: *mut SoundSource, _: *mut c_void)> )
Equivalent to setLoopCallback
sourcepub fn fade_volume(
&self,
left: f32,
right: f32,
len: i32,
finish_callback: Option<unsafe extern "C" fn(_: *mut SoundSource, _: *mut c_void)>
)
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
sourcepub 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
)
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§
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 Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
§impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
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.