Trait StreamTrait
pub trait StreamTrait {
// Required methods
fn play(&self) -> Result<(), PlayStreamError> ⓘ;
fn pause(&self) -> Result<(), PauseStreamError> ⓘ;
}
Available on crate feature
dep_rodio
only.Expand description
A stream created from Device
, with methods to control playback.
Required Methods§
fn play(&self) -> Result<(), PlayStreamError> ⓘ
fn play(&self) -> Result<(), PlayStreamError> ⓘ
Run the stream.
Note: Not all platforms automatically run the stream upon creation, so it is important to
call play
after creation if it is expected that the stream should run immediately.
fn pause(&self) -> Result<(), PauseStreamError> ⓘ
fn pause(&self) -> Result<(), PauseStreamError> ⓘ
Some devices support pausing the audio stream. This can be useful for saving energy in moments of silence.
Note: Not all devices support suspending the stream at the hardware level. This method may fail in these cases.