This bevy plugin is intended to test an integration of Kira into Bevy. The goal is to replace or update bevy_audio
, if Kira turns out to be a good approach. Currently, this plugin can play ogg
, mp3
, flac
, and wav
formats and supports web builds.
Sound can be played in channels. Each channel has controls to pause or stop playback and can change the volume, playback speed, and panning of all sounds playing in it. You can easily add new channels and access them through Bevy's ECS (see the custom_channel
example).
Note: the Bevy feature bevy_audio
is enabled by default and not compatible with this plugin. Make sure to not have the bevy_audio
feature enabled if you want to use bevy_kira_audio
. The same goes for Bevy's vorbis
feature. See Bevys' Cargo file for a list of all default features of version 0.7
and list them manually in your Cargo file excluding the ones you do not want. Make sure to set default-features
to false for the Bevy dependency in your Cargo file. You can take a look at bevy_game_template's cargo file as an example.
To play audio, you usually want to load audio files as assets. This requires AssetLoaders
. bevy_kira_audio
comes with loaders for most common audio formats. You can enable them with the features ogg
(enabled by default), mp3
, wav
, or flac
. The following example assumes that the feature ogg
is enabled.
```rust norun use bevykira_audio::{Audio, AudioPlugin}; use bevy::prelude::*;
fn main() { App::new() .addplugins(DefaultPlugins) .addplugin(AudioPlugin) .addstartupsystem(startbackgroundaudio) .run(); }
fn startbackgroundaudio(assetserver: Res
Requires feature settings_loader
It is possible to load sounds with custom settings from ron
files. A common example would be a loop with an intro. Loading a ron file like this:
```ron
(
// The actual sound file in your assets directory
file: "sounds/loop.ogg",
loop_behavior: Some(3.0),
) ``` would make the loaded sound loop by default and start each repeated playback three seconds into the sound (the three seconds are the intro).
More settings are available. See the settings_loader
example for all options.
ogg
mp3
wav
flac
index.html
file (usage example).status
example)The main branch is compatible with the latest Bevy release.
Compatibility of bevy_kira_audio
versions:
| bevy_kira_audio
| bevy
|
| :-- | :-- |
| 0.9
- 0.10
| 0.7
|
| 0.8
| 0.6
|
| 0.4
- 0.7
| 0.5
|
| 0.3
| 0.4
|
| main
| 0.7
|
| bevy_main
| main
|
Licensed under either of
at your option.
Assets in the examples might be distributed under different terms. See the readme in the examples
directory.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.