This bevy plugin is intended to try integrating 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 for everything except mp3
. It also supports streaming of generated audio.
You can check out the examples
directory in this repository for a display of this plugin's functionality.
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 mp3
feature. See Bevys' Cargo file for a list of all default features of version 0.5.0
and list them manually in your Cargo file excluding the ones you do not want.
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::{AudioChannel, Audio, AudioPlugin}; use bevy::prelude::*;
fn main() { let mut app = App::build(); app .addplugins(DefaultPlugins) .addplugin(AudioPlugin) .addstartupsystem(startbackgroundaudio.system()); app.run(); }
fn startbackgroundaudio(assetserver: Res
ogg
mp3
wav
flac
ogg
, flac
and wav
can be build for WASM and used in web builds. There are some differences between browsers:index.html
file (usage example).status
example)Currently, sound settings are hard to control and usually your audio files get loaded with the default. With the feature settings_loader
it is possible to define an audio asset with non-default semantic duration. The semantic_duration example demonstrates loading and playing such an asset. More options will likely be supported in the future.
The main branch is compatible with the latest Bevy release, while the branch bevy_main
tracks the main
branch of Bevy.
Compatibility of bevy_kira_audio
versions:
| bevy_kira_audio
| bevy
|
| :-- | :-- |
| 0.4
- 0.7
| 0.5
|
| 0.3
| 0.4
|
| main
| 0.5
|
| 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.