Crates.io | bevy_audio_controller |
lib.rs | bevy_audio_controller |
version | 0.2.3 |
source | src |
created_at | 2024-11-05 21:12:27.349918 |
updated_at | 2024-11-13 14:18:26.997919 |
description | Bevy plugin for managed audio playback |
homepage | https://github.com/TurtIeSocks/bevy_audio_controller |
repository | https://github.com/TurtIeSocks/bevy_audio_controller |
max_upload_size | |
id | 1437166 |
size | 216,528 |
An extremely convenient plugin that provides a solid audio controller for Bevy with very minimal boilerplate!
AssetServer
directly and provides a convenient enum so you can avoid "magic strings" in your coderegister_audio_channel
trait to allow you to easily add multiple audio channels to your appAudioChannel
derive macro adds convenient methods to the channel marker structuse bevy::{prelude::*, audio::PlaybackSettings};
use bevy_audio_controller::prelude::*;
#[derive(Component, Default, AudioChannel)]
struct SfxChannel;
type SfxEvent = PlayEvent<SfxChannel>;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(AudioControllerPlugin)
.register_audio_channel::<SfxChannel>()
.add_systems(Update, play_fire)
.run();
}
fn play_fire(mut ew: EventWriter<SfxEvent>) {
// even though this is called on every frame, it will only be played once the previous clip has finished
ew.send(SfxEvent::new(AudioFiles::FireOGG).with_settings(PlaybackSettings::DESPAWN));
}
default
None
inspect
Adds additional reflection traits to the structs used by this plugin to make them available in bevy-egui-inspector
Requires that channel components must also derive Reflect
// If you are using the `inspect` feature conditionally, you can use the following pattern
#[derive(Component, Default, AudioChannel)]
#[cfg_attr(feature = "inspect", derive(Reflect))]
#[cfg_attr(feature = "inspect", reflect(Component))]
struct SfxChannel;
// Otherwise, this is fine
#[derive(Component, Default, AudioChannel, Reflect)]
#[reflect(Component)]
struct MusicChannel;
mp3
Enables support for MP3 audio files.
ogg
Enables support for OGG audio files
flac
Enables support for FLAC audio files
wav
Enables support for WAV audio files
all-codecs
Enables support for all audio codecs
All examples require --features="ogg"
flag to work. If you would like to view more details with bevy-egui-inspector, run with --all-features
instead.
Demonstrates:
Inputs:
cargo run --example basic --features="ogg"
Demonstrates:
cargo run --example channels --features="ogg"
Demonstrates:
Inputs:
cargo run --example event_options --features="ogg"
Demonstrates:
Inputs:
DelayMode::Immediate
cargo run --example ecs --features="ogg"
Demonstrates:
Percent
& Milliseconds
variations of the DelayMode
enum for finer control over when a track is played cargo run --example delays --features="ogg"
Demonstrates:
Inputs:
cargo run --example volume --features="ogg"
Demonstrates:
cargo run --example querying --features="ogg"
bevy | bevy_audio_controller |
---|---|
0.14 | 0.2 |