2020-10-20 18:44:50 +00:00
|
|
|
mod audio;
|
2020-07-16 20:46:51 +00:00
|
|
|
mod audio_output;
|
|
|
|
mod audio_source;
|
|
|
|
|
2020-10-20 18:44:50 +00:00
|
|
|
pub use audio::*;
|
2020-07-16 20:46:51 +00:00
|
|
|
pub use audio_output::*;
|
|
|
|
pub use audio_source::*;
|
|
|
|
|
2020-07-17 02:20:51 +00:00
|
|
|
pub mod prelude {
|
2020-10-20 18:44:50 +00:00
|
|
|
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::*;
|
2020-07-16 20:46:51 +00:00
|
|
|
use bevy_asset::AddAsset;
|
2020-10-20 18:44:50 +00:00
|
|
|
use bevy_ecs::IntoThreadLocalSystem;
|
2020-07-16 20:46:51 +00:00
|
|
|
|
2020-08-09 23:13:04 +00:00
|
|
|
/// Adds support for audio playback to an App
|
2020-07-16 20:46:51 +00:00
|
|
|
#[derive(Default)]
|
|
|
|
pub struct AudioPlugin;
|
|
|
|
|
2020-08-08 03:22:17 +00:00
|
|
|
impl Plugin for AudioPlugin {
|
2020-07-16 20:46:51 +00:00
|
|
|
fn build(&self, app: &mut AppBuilder) {
|
2020-10-20 18:44:50 +00:00
|
|
|
app.init_thread_local_resource::<AudioOutput<AudioSource>>()
|
2020-07-16 20:46:51 +00:00
|
|
|
.add_asset::<AudioSource>()
|
2020-10-18 20:48:15 +00:00
|
|
|
.init_asset_loader::<Mp3Loader>()
|
2020-10-20 18:44:50 +00:00
|
|
|
.init_resource::<Audio<AudioSource>>()
|
2020-09-08 20:56:45 +00:00
|
|
|
.add_system_to_stage(
|
|
|
|
stage::POST_UPDATE,
|
2020-10-20 18:44:50 +00:00
|
|
|
play_queued_audio_system::<AudioSource>.thread_local_system(),
|
2020-09-08 20:56:45 +00:00
|
|
|
);
|
2020-07-16 20:46:51 +00:00
|
|
|
}
|
|
|
|
}
|