pub struct Source { /* private fields */ }
Expand description
A source of audio data that is connected to an output channel and ready to play. It will stop playing when dropped.
Implementations§
source§impl Source
impl Source
sourcepub fn new<P: AsRef<Path>>(
ctxs: &impl Has<AudioContext>,
path: P
) -> GameResult<Self>
pub fn new<P: AsRef<Path>>( ctxs: &impl Has<AudioContext>, path: P ) -> GameResult<Self>
Create a new Source
from the given file.
sourcepub fn from_data(
audio: &impl Has<AudioContext>,
data: SoundData
) -> GameResult<Self>
pub fn from_data( audio: &impl Has<AudioContext>, data: SoundData ) -> GameResult<Self>
Creates a new Source
using the given SoundData
object.
Trait Implementations§
source§impl SoundSource for Source
impl SoundSource for Source
source§fn play_later(&self) -> GameResult
fn play_later(&self) -> GameResult
Plays the
SoundSource
; waits until done if the sound is currently playingsource§fn play_detached(&mut self, audio: &impl Has<AudioContext>) -> GameResult
fn play_detached(&mut self, audio: &impl Has<AudioContext>) -> GameResult
Play source “in the background”; cannot be stopped
source§fn set_repeat(&mut self, repeat: bool)
fn set_repeat(&mut self, repeat: bool)
Sets the source to repeat playback infinitely on next
play()
source§fn set_fade_in(&mut self, dur: Duration)
fn set_fade_in(&mut self, dur: Duration)
Sets the fade-in time of the source
source§fn set_start(&mut self, dur: Duration)
fn set_start(&mut self, dur: Duration)
Sets the time from which playback begins, skipping audio up to that point. Read more
source§fn stop(&mut self, audio: &impl Has<AudioContext>) -> GameResult
fn stop(&mut self, audio: &impl Has<AudioContext>) -> GameResult
Stops playback
source§fn stopped(&self) -> bool
fn stopped(&self) -> bool
Returns whether or not the source is stopped
– that is, has no more data to play.
source§fn set_volume(&mut self, value: f32)
fn set_volume(&mut self, value: f32)
Sets the current volume.
source§fn playing(&self) -> bool
fn playing(&self) -> bool
Get whether or not the source is playing (ie, not paused
and not stopped).
source§fn set_query_interval(&mut self, t: Duration)
fn set_query_interval(&mut self, t: Duration)
Set the update interval of the internal sample counter. Read more
source§fn play(&mut self, audio: &impl Has<AudioContext>) -> GameResult
fn play(&mut self, audio: &impl Has<AudioContext>) -> GameResult
Plays the audio source; restarts the sound if currently playing
Auto Trait Implementations§
impl RefUnwindSafe for Source
impl Send for Source
impl Sync for Source
impl Unpin for Source
impl UnwindSafe for Source
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
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
source§impl<T> HasMut<T> for T
impl<T> HasMut<T> for T
source§fn retrieve_mut(&mut self) -> &mut T
fn retrieve_mut(&mut self) -> &mut T
Method to retrieve the context type as mutable.