-
Hello ! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You already can actually!
use kira::{
manager::{AudioManager, AudioManagerSettings, DefaultBackend},
sound::static_sound::StaticSoundData,
};
fn main() {
use std::io::Cursor;
let bytes = include_bytes!("wild-cherry-play-that-funky-music.mp3");
let cursor = Cursor::new(bytes);
let data = StaticSoundData::from_cursor(cursor).expect("read static sound data from cursor");
let duration = data.duration();
let mut manager: AudioManager<DefaultBackend> =
AudioManager::new(AudioManagerSettings::default()).expect("audio manager");
manager.play(data).expect("play sound data");
std::thread::sleep(duration);
// depending on its size, you can experience some latency before sound gets loaded in memory and played
} |
Beta Was this translation helpful? Give feedback.
You already can actually!
include_bytes!()
yields a&'static [u8; N]
, which implementsAsRef<[u8]> + 'static
and can be wrapped into aCursor<&[u8]>
, which bothStaticSoundData
andStreamingSoundData
support with from_cursor :