pub struct Audio {
pub channel: Sender<AudioCommand>,
}Expand description
Holds the command channel
Fields§
§channel: Sender<AudioCommand>Tokio mpsc sender used to communicate with the audio thread
Implementations§
Source§impl Audio
impl Audio
Sourcepub async fn play_audio(
&mut self,
path: &Path,
_interrupt_current_playback: bool,
) -> Result<()>
pub async fn play_audio( &mut self, path: &Path, _interrupt_current_playback: bool, ) -> Result<()>
Sends a Play command for the given path
Examples found in repository?
examples/hello.rs (line 49)
43 fn key_down_event(&self, window: &mut Window, event: KeyboardEvent) -> anyhow::Result<()> {
44 println!("{:?}", event.keycode);
45 tokio::task::block_in_place(move || {
46 Handle::current().block_on(async move {
47 window
48 .audio
49 .play_audio(Path::new("assets/music.ogg"), false)
50 .await
51 .unwrap();
52 })
53 });
54 Ok(())
55 }Trait Implementations§
Auto Trait Implementations§
impl Freeze for Audio
impl RefUnwindSafe for Audio
impl Send for Audio
impl Sync for Audio
impl Unpin for Audio
impl UnwindSafe for Audio
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().