bevy/crates/bevy_audio/src/lib.rs

33 lines
835 B
Rust
Raw Normal View History

mod audio;
mod audio_output;
mod audio_source;
pub use audio::*;
pub use audio_output::*;
pub use audio_source::*;
2020-07-17 02:20:51 +00:00
pub mod prelude {
pub use crate::{Audio, AudioOutput, AudioSource, Decodable};
2020-07-17 02:20:51 +00:00
}
2020-07-17 01:47:51 +00:00
use bevy_app::prelude::*;
use bevy_asset::AddAsset;
use bevy_ecs::IntoThreadLocalSystem;
/// Adds support for audio playback to an App
#[derive(Default)]
pub struct AudioPlugin;
2020-08-08 03:22:17 +00:00
impl Plugin for AudioPlugin {
fn build(&self, app: &mut AppBuilder) {
app.init_thread_local_resource::<AudioOutput<AudioSource>>()
.add_asset::<AudioSource>()
.init_asset_loader::<Mp3Loader>()
.init_resource::<Audio<AudioSource>>()
.add_system_to_stage(
stage::POST_UPDATE,
play_queued_audio_system::<AudioSource>.thread_local_system(),
);
}
}