docs/bevy/examples/audio/audio.rs 486 B · 17 lines · raw · history
| 1 | //! This example illustrates how to load and play an audio file. |
| 2 | //! For loading additional audio formats, you can enable the corresponding feature for that audio format. |
| 3 | |
| 4 | use bevy::prelude::*; |
| 5 | |
| 6 | fn main() { |
| 7 | App::new() |
| 8 | .add_plugins(DefaultPlugins) |
| 9 | .add_systems(Startup, setup) |
| 10 | .run(); |
| 11 | } |
| 12 | |
| 13 | fn setup(asset_server: Res<AssetServer>, mut commands: Commands) { |
| 14 | commands.spawn(AudioPlayer::new( |
| 15 | asset_server.load("sounds/Windless Slopes.ogg"), |
| 16 | )); |
| 17 | } |