2020-10-20 14:44:50 -04:00
|
|
|
mod audio;
|
2020-07-16 13:46:51 -07:00
|
|
|
mod audio_output;
|
|
|
|
mod audio_source;
|
|
|
|
|
2020-07-16 19:20:51 -07:00
|
|
|
pub mod prelude {
|
2020-10-20 14:44:50 -04:00
|
|
|
pub use crate::{Audio, AudioOutput, AudioSource, Decodable};
|
2020-07-16 19:20:51 -07:00
|
|
|
}
|
|
|
|
|
2021-02-19 00:20:37 +03:00
|
|
|
pub use audio::*;
|
|
|
|
pub use audio_output::*;
|
|
|
|
pub use audio_source::*;
|
|
|
|
|
2020-07-16 18:47:51 -07:00
|
|
|
use bevy_app::prelude::*;
|
2020-07-16 13:46:51 -07:00
|
|
|
use bevy_asset::AddAsset;
|
2021-02-09 23:14:10 +03:00
|
|
|
use bevy_ecs::IntoExclusiveSystem;
|
2020-07-16 13:46:51 -07:00
|
|
|
|
2020-08-09 16:13:04 -07:00
|
|
|
/// Adds support for audio playback to an App
|
2020-07-16 13:46:51 -07:00
|
|
|
#[derive(Default)]
|
|
|
|
pub struct AudioPlugin;
|
|
|
|
|
2020-08-07 20:22:17 -07:00
|
|
|
impl Plugin for AudioPlugin {
|
2020-07-16 13:46:51 -07:00
|
|
|
fn build(&self, app: &mut AppBuilder) {
|
2021-02-09 23:14:10 +03:00
|
|
|
app.init_non_send_resource::<AudioOutput<AudioSource>>()
|
2020-07-16 13:46:51 -07:00
|
|
|
.add_asset::<AudioSource>()
|
2020-10-18 13:48:15 -07:00
|
|
|
.init_asset_loader::<Mp3Loader>()
|
2020-10-20 14:44:50 -04:00
|
|
|
.init_resource::<Audio<AudioSource>>()
|
2020-12-15 21:57:16 -08:00
|
|
|
.add_system_to_stage(
|
2021-02-19 00:20:37 +03:00
|
|
|
CoreStage::PostUpdate,
|
2021-02-09 23:14:10 +03:00
|
|
|
play_queued_audio_system::<AudioSource>.exclusive_system(),
|
2020-12-15 21:57:16 -08:00
|
|
|
);
|
2020-07-16 13:46:51 -07:00
|
|
|
}
|
|
|
|
}
|