pub struct StreamHandle { /* private fields */ }Expand description
Controls one playing AudioStream, as returned by crate::Audio::play_stream.
Dropping the handle does not stop the stream; it plays until StreamHandle::stop.
Clones refer to the same stream. Changes apply from the next audio block, and volume
changes, pausing and stopping ramp over that block so they do not click.
Implementations§
Source§impl StreamHandle
impl StreamHandle
Sourcepub fn set_volume(&self, volume: f32)
pub fn set_volume(&self, volume: f32)
Set the volume as a linear amplitude (1.0 is the stream’s own level, 0.0 silence).
Sourcepub fn pause(&self)
pub fn pause(&self)
Pause: the stream fades out over one audio block, then outputs silence and is not asked for samples until resumed.
Sourcepub fn resume(&self)
pub fn resume(&self)
Resume a paused stream where it left off, fading back in over one audio block.
Sourcepub fn stop(&self)
pub fn stop(&self)
Stop the stream for good; it fades out over one audio block and is then dropped from the mixer.
Sourcepub fn is_playing(&self) -> bool
pub fn is_playing(&self) -> bool
Whether the stream is audible: started, not paused and not stopped.
Sourcepub fn is_pending(&self) -> bool
pub fn is_pending(&self) -> bool
Whether the stream is still waiting for audio to start.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether the stream was stopped.
Trait Implementations§
Source§impl Clone for StreamHandle
impl Clone for StreamHandle
Source§fn clone(&self) -> StreamHandle
fn clone(&self) -> StreamHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Forget for StreamHandle
impl Freeze for StreamHandle
impl RefUnwindSafe for StreamHandle
impl Send for StreamHandle
impl Sync for StreamHandle
impl Unpin for StreamHandle
impl UnsafeUnpin for StreamHandle
impl UnwindSafe for StreamHandle
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.