pub struct Speaker<S: Sdk> { /* private fields */ }Expand description
The SDK’s speaker.
Implementations§
Trait Implementations§
Source§impl<S: Sdk> Backend for Speaker<S>
impl<S: Sdk> Backend for Speaker<S>
Source§fn load_sound(
&mut self,
_bytes: &[u8],
) -> impl Future<Output = Result<Clip<S>, String>>
fn load_sound( &mut self, _bytes: &[u8], ) -> impl Future<Output = Result<Clip<S>, String>>
The SDK loads a sound by its path (load_sound_file):
it is baked to a format only pdc writes, and no bytes come here.
Source§fn add_sound(&mut self, samples: &SharedSamples) -> Result<Clip<S>, String>
fn add_sound(&mut self, samples: &SharedSamples) -> Result<Clip<S>, String>
A sample the SDK makes from a copy of the samples, at their own rate.
Source§fn remove_sound(&mut self, sound: Clip<S>)
fn remove_sound(&mut self, sound: Clip<S>)
Stops the sample players on it, lets go of it, and frees it.
Source§fn load_sound_file(
&mut self,
file: &str,
_files: &Files<'_>,
) -> impl Future<Output = Result<Clip<S>, String>>
fn load_sound_file( &mut self, file: &str, _files: &Files<'_>, ) -> impl Future<Output = Result<Clip<S>, String>>
Readies the sound file
file of the manifest. By default it reads
the file with files and decodes it with
load_sound; a device that loads a sound from
its own path says so here.Source§fn load_music(&mut self, path: &str) -> Self::Loading
fn load_music(&mut self, path: &str) -> Self::Loading
Starts loading and decoding the music or voice file at
path.Source§fn poll_music(
&mut self,
loading: &mut Self::Loading,
) -> Option<Result<Clip<S>, String>>
fn poll_music( &mut self, loading: &mut Self::Loading, ) -> Option<Result<Clip<S>, String>>
The track, once
loading has finished (called once per frame).Source§fn length(&self, sound: &Clip<S>) -> Option<f64>
fn length(&self, sound: &Clip<S>) -> Option<f64>
How long
sound plays, in seconds, if that is known: it is for an
OGG file loaded with load_music.Source§fn play(&mut self, sound: &Clip<S>, volume: f32, looped: bool) -> Playing<S>
fn play(&mut self, sound: &Clip<S>, volume: f32, looped: bool) -> Playing<S>
Plays
sound from the start at volume (0–1): this playback.Source§fn set_volume(&mut self, sound: &Clip<S>, volume: f32)
fn set_volume(&mut self, sound: &Clip<S>, volume: f32)
Changes the volume of
sound wherever it plays.Source§fn set_playing_volume(&mut self, playing: &Playing<S>, volume: f32)
fn set_playing_volume(&mut self, playing: &Playing<S>, volume: f32)
Changes the volume of
playing alone.Source§fn stop_playing(&mut self, playing: Playing<S>)
fn stop_playing(&mut self, playing: Playing<S>)
Stops
playing alone: other copies of its sound play on.Source§fn pause(&mut self, playing: &Playing<S>) -> Result<(), Unsupported>
fn pause(&mut self, playing: &Playing<S>) -> Result<(), Unsupported>
Stops
playing so that resume goes on from where
it was. Without it the player mutes the sound, which runs on silently.Source§fn resume(&mut self, playing: &Playing<S>) -> Result<(), Unsupported>
fn resume(&mut self, playing: &Playing<S>) -> Result<(), Unsupported>
Goes on with
playing from where pause stopped it.Source§fn warn(&mut self, line: &str)
fn warn(&mut self, line: &str)
Says a problem of the player’s in the backend’s log, by default
nowhere.
Source§fn hold_output(&mut self, on: bool)
fn hold_output(&mut self, on: bool)
The system suspends the game (
on) or has resumed it: a backend whose output
can stop stops it here, after the player has held what sounds.Auto Trait Implementations§
impl<S> Freeze for Speaker<S>where
S: Freeze,
impl<S> RefUnwindSafe for Speaker<S>
impl<S> Send for Speaker<S>
impl<S> Sync for Speaker<S>
impl<S> Unpin for Speaker<S>
impl<S> UnsafeUnpin for Speaker<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for Speaker<S>where
S: UnwindSafe,
<S as Sdk>::Sample: RefUnwindSafe + UnwindSafe,
<S as Sdk>::SamplePlayer: UnwindSafe,
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
Mutably borrows from an owned value. Read more