# Bevy Audio Systems

Bevy ECS skill for audio playback.

- Repository: https://github.com/thedivergentai/Game-Dev-Agentic-Skills (917 stars)
- Category: Media
- License: LGPL-3.0
- Last updated: 2026-10-16
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-audio-systems -g -a claude-code -y`
Codex: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-audio-systems -g -a codex -y`
Cursor: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-audio-systems -g -a cursor -y`
Gemini CLI: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-audio-systems -g -a gemini-cli -y`

## Description

Bevy ECS skill for audio playback. Keywords: Bevy, AudioPlayer, AudioSink, PlaybackSettings, AssetServer.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Bevy audio systems

## When to use

Load this when a clip should start, loop, pause, or change volume. `bevy::audio` in Bevy 0.20 and the `audio_control` example are the sources.

## ECS shape

- **Play:** spawn `AudioPlayer::new(asset_server.load(...))`. `AudioPlayer<Source>` holds `Handle<Source>` where `Source: Asset + Decodable`. If the asset is not ready, playback starts when it is. `AudioPlayer` requires `PlaybackSettings`.
- **Settings:** `PlaybackSettings` configures the start. `PlaybackSettings::LOOP` and `.with_spatial(true)` appear in the spatial examples. Changes to `PlaybackSettings` do not affect audio that is already playing. `PlaybackMode` is `Once`, `Loop`, `Despawn`, or `Remove`.
- **Control:** when playback begins, Bevy inserts `AudioSink`. The control example queries `AudioSink` and calls `pause`, `toggle_mute`, `set_volume`, `set_speed`, and `position`. `SpatialAudioSink` is the spatial counterpart named on the playback page.
- **Replay:** after a non-looping sound finishes and the sink is drained, that `AudioPlayer` cannot be reused. Remove the audio components and add them again.
- **Schedule:** spawn on `Startup` or from a system that has `Res<AssetServer>` and `Commands`. Control systems in the example run where they read `ButtonInput<KeyCode>` and `Res<Time>`.

## Playback pieces

| Need | Bevy idiom |
| --- | --- |
| Start a file | `AudioPlayer::new` plus `AssetServer::load` |
| Loop | `PlaybackSettings::LOOP` |
| Pause, mute, or volume while playing | `AudioSink` methods on the same entity |
| One-shot that should leave the world | `PlaybackMode::Despawn` or `Remove` |
| Positional emitter | `PlaybackSettings` with `with_spatial(true)` and `SpatialAudioSink` |

## Examples

```toml
[dependencies]
bevy = "0.20"
```

`AudioPlayer` starts when the handle is ready. `PlaybackSettings` applies only at that start. `AudioSink` is inserted once playback begins and is the live control.

```rust
use bevy::audio::{AudioSinkPlayback, Volume};

The rest: https://github.com/thedivergentai/Game-Dev-Agentic-Skills/blob/HEAD/skills/bevy-audio-systems/SKILL.md
