This is extracted out of eb8f973646476b4a4926ba644a77e2b3a5772159 and includes some additional changes to remove all references to AppBuilder and fix examples that still used App::build() instead of App::new(). In addition I didn't extract the sub app feature as it isn't ready yet. You can use `git diff --diff-filter=M eb8f973646476b4a4926ba644a77e2b3a5772159` to find all differences in this PR. The `--diff-filtered=M` filters all files added in the original commit but not in this commit away. Co-Authored-By: Carter Anderson <mcanders1@gmail.com>
36 lines
942 B
Rust
36 lines
942 B
Rust
mod audio;
|
|
mod audio_output;
|
|
mod audio_source;
|
|
|
|
pub mod prelude {
|
|
#[doc(hidden)]
|
|
pub use crate::{Audio, AudioOutput, AudioSource, Decodable};
|
|
}
|
|
|
|
pub use audio::*;
|
|
pub use audio_output::*;
|
|
pub use audio_source::*;
|
|
|
|
use bevy_app::prelude::*;
|
|
use bevy_asset::AddAsset;
|
|
use bevy_ecs::system::IntoExclusiveSystem;
|
|
|
|
/// Adds support for audio playback to an App
|
|
#[derive(Default)]
|
|
pub struct AudioPlugin;
|
|
|
|
impl Plugin for AudioPlugin {
|
|
fn build(&self, app: &mut App) {
|
|
app.init_non_send_resource::<AudioOutput<AudioSource>>()
|
|
.add_asset::<AudioSource>()
|
|
.init_resource::<Audio<AudioSource>>()
|
|
.add_system_to_stage(
|
|
CoreStage::PostUpdate,
|
|
play_queued_audio_system::<AudioSource>.exclusive_system(),
|
|
);
|
|
|
|
#[cfg(any(feature = "mp3", feature = "flac", feature = "wav", feature = "vorbis"))]
|
|
app.init_asset_loader::<Mp3Loader>();
|
|
}
|
|
}
|