pub struct Audio {
pub channel: Sender<AudioCommand>,
pub cached_audio: HashMap<String, Box<Cursor<Vec<u8>>>>,
}Fields§
§channel: Sender<AudioCommand>§cached_audio: HashMap<String, Box<Cursor<Vec<u8>>>>Implementations§
Source§impl Audio
impl Audio
pub fn new() -> Audio
pub fn load_asset(&mut self, path: &Path) -> Result<()>
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<()>
Examples found in repository?
examples/hello.rs (lines 44-47)
28 fn key_down_event(
29 &self,
30 game: &mut Game,
31 _timestamp: u64,
32 _window_id: u32,
33 keycode: Option<sdl3::keyboard::Keycode>,
34 _scancode: Option<sdl3::keyboard::Scancode>,
35 _keymod: sdl3::keyboard::Mod,
36 _repeat: bool,
37 _which: u32,
38 _raw: u16,
39 ) -> anyhow::Result<()> {
40 println!("{:?}", keycode);
41 tokio::task::block_in_place(move || {
42 Handle::current().block_on(async move {
43 game.audio
44 .play_audio(
45 Path::new("examples/music.ogg"),
46 false,
47 )
48 .await
49 .unwrap();
50 })
51 });
52 Ok(())
53 }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().