Trait bevy_kira_audio::AudioApp
source · pub trait AudioApp {
// Required method
fn add_audio_channel<T: Resource>(&mut self) -> &mut Self;
}
Expand description
Extension trait to add new audio channels to the application
Required Methods§
sourcefn add_audio_channel<T: Resource>(&mut self) -> &mut Self
fn add_audio_channel<T: Resource>(&mut self) -> &mut Self
Add a new audio channel to the application
use bevy::prelude::*;
use bevy_kira_audio::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(AudioPlugin)
.add_audio_channel::<Background>()
.add_systems(Startup, play)
.run();
}
fn play(background: Res<AudioChannel<Background>>, asset_server: Res<AssetServer>) {
background.play(asset_server.load("sounds/loop.ogg"));
}
#[derive(Resource)]
struct Background;
Object Safety§
This trait is not object safe.