19 lines
11 KiB
HTML
19 lines
11 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Audio support for the game engine Bevy"><title>bevy_audio - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="bevy_audio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0 (9fc6b4312 2025-01-07)" data-channel="1.84.0" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://bevyengine.org/assets/icon.png"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../bevy_audio/index.html"><img src="https://bevyengine.org/assets/icon.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../bevy_audio/index.html"><img src="https://bevyengine.org/assets/icon.png" alt="logo"></a><h2><a href="../bevy_audio/index.html">bevy_<wbr>audio</a><span class="version">0.15.1</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#types" title="Type Aliases">Type Aliases</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>bevy_audio</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/bevy_audio/lib.rs.html#1-125">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Audio support for the game engine Bevy</p>
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">fn </span>main() {
|
|
App::new()
|
|
.add_plugins((MinimalPlugins, AssetPlugin::default(), AudioPlugin::default()))
|
|
.add_systems(Startup, play_background_audio)
|
|
.run();
|
|
}
|
|
|
|
<span class="kw">fn </span>play_background_audio(asset_server: Res<AssetServer>, <span class="kw-2">mut </span>commands: Commands) {
|
|
commands.spawn((
|
|
AudioPlayer::new(asset_server.load(<span class="string">"background_audio.ogg"</span>)),
|
|
PlaybackSettings::LOOP,
|
|
));
|
|
}</code></pre></div>
|
|
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="prelude/index.html" title="mod bevy_audio::prelude">prelude</a></div><div class="desc docblock-short">The audio prelude.</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.AudioLoader.html" title="struct bevy_audio::AudioLoader">Audio<wbr>Loader</a></div><div class="desc docblock-short">Loads files as <a href="struct.AudioSource.html" title="struct bevy_audio::AudioSource"><code>AudioSource</code></a> <a href="../bevy_asset/assets/struct.Assets.html" title="struct bevy_asset::assets::Assets"><code>Assets</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.AudioPlayer.html" title="struct bevy_audio::AudioPlayer">Audio<wbr>Player</a></div><div class="desc docblock-short">A component for playing a sound.</div></li><li><div class="item-name"><a class="struct" href="struct.AudioPlugin.html" title="struct bevy_audio::AudioPlugin">Audio<wbr>Plugin</a></div><div class="desc docblock-short">Adds support for audio playback to a Bevy Application</div></li><li><div class="item-name"><a class="struct" href="struct.AudioSink.html" title="struct bevy_audio::AudioSink">Audio<wbr>Sink</a></div><div class="desc docblock-short">Used to control audio during playback.</div></li><li><div class="item-name"><a class="struct" href="struct.AudioSource.html" title="struct bevy_audio::AudioSource">Audio<wbr>Source</a></div><div class="desc docblock-short">A source of audio data</div></li><li><div class="item-name"><a class="struct" href="struct.AudioSourceBundle.html" title="struct bevy_audio::AudioSourceBundle">Audio<wbr>Source<wbr>Bundle</a><wbr><span class="stab deprecated" title="">Deprecated</span></div><div class="desc docblock-short">Bundle for playing a sound.</div></li><li><div class="item-name"><a class="struct" href="struct.DefaultSpatialScale.html" title="struct bevy_audio::DefaultSpatialScale">Default<wbr>Spatial<wbr>Scale</a></div><div class="desc docblock-short">The default scale factor applied to the positions of audio sources and listeners for
|
|
spatial audio. Can be overridden for individual sounds in <a href="struct.PlaybackSettings.html" title="struct bevy_audio::PlaybackSettings"><code>PlaybackSettings</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.GlobalVolume.html" title="struct bevy_audio::GlobalVolume">Global<wbr>Volume</a></div><div class="desc docblock-short">Use this <a href="../bevy_ecs/system/system_param/trait.Resource.html" title="trait bevy_ecs::system::system_param::Resource"><code>Resource</code></a> to control the global volume of all audio.</div></li><li><div class="item-name"><a class="struct" href="struct.Pitch.html" title="struct bevy_audio::Pitch">Pitch</a></div><div class="desc docblock-short">A source of sine wave sound</div></li><li><div class="item-name"><a class="struct" href="struct.PlaybackSettings.html" title="struct bevy_audio::PlaybackSettings">Playback<wbr>Settings</a></div><div class="desc docblock-short">Initial settings to be used when audio starts playing.</div></li><li><div class="item-name"><a class="struct" href="struct.SpatialAudioSink.html" title="struct bevy_audio::SpatialAudioSink">Spatial<wbr>Audio<wbr>Sink</a></div><div class="desc docblock-short">Used to control spatial audio during playback.</div></li><li><div class="item-name"><a class="struct" href="struct.SpatialListener.html" title="struct bevy_audio::SpatialListener">Spatial<wbr>Listener</a></div><div class="desc docblock-short">Settings for the listener for spatial audio sources.</div></li><li><div class="item-name"><a class="struct" href="struct.SpatialScale.html" title="struct bevy_audio::SpatialScale">Spatial<wbr>Scale</a></div><div class="desc docblock-short">A scale factor applied to the positions of audio sources and listeners for
|
|
spatial audio.</div></li><li><div class="item-name"><a class="struct" href="struct.Volume.html" title="struct bevy_audio::Volume">Volume</a></div><div class="desc docblock-short">A volume level equivalent to a non-negative float.</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.PlaybackMode.html" title="enum bevy_audio::PlaybackMode">Playback<wbr>Mode</a></div><div class="desc docblock-short">The way Bevy manages the sound playback.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.AddAudioSource.html" title="trait bevy_audio::AddAudioSource">AddAudio<wbr>Source</a></div><div class="desc docblock-short">A trait that allows adding a custom audio source to the object.
|
|
This is implemented for <a href="../bevy_app/app/struct.App.html" title="struct bevy_app::app::App"><code>App</code></a> to allow registering custom <a href="trait.Decodable.html" title="trait bevy_audio::Decodable"><code>Decodable</code></a> types.</div></li><li><div class="item-name"><a class="trait" href="trait.AudioSinkPlayback.html" title="trait bevy_audio::AudioSinkPlayback">Audio<wbr>Sink<wbr>Playback</a></div><div class="desc docblock-short">Common interactions with an audio sink.</div></li><li><div class="item-name"><a class="trait" href="trait.CpalSample.html" title="trait bevy_audio::CpalSample">Cpal<wbr>Sample</a></div><div class="desc docblock-short">A trait for working generically across different <strong>Sample</strong> format types.</div></li><li><div class="item-name"><a class="trait" href="trait.Decodable.html" title="trait bevy_audio::Decodable">Decodable</a></div><div class="desc docblock-short">A type implementing this trait can be converted to a <a href="trait.Source.html" title="trait bevy_audio::Source"><code>rodio::Source</code></a> type.</div></li><li><div class="item-name"><a class="trait" href="trait.Sample.html" title="trait bevy_audio::Sample">Sample</a></div><div class="desc docblock-short">Represents a value of a single sample.</div></li><li><div class="item-name"><a class="trait" href="trait.Source.html" title="trait bevy_audio::Source">Source</a></div><div class="desc docblock-short">A source of samples.</div></li></ul><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="type" href="type.AudioBundle.html" title="type bevy_audio::AudioBundle">Audio<wbr>Bundle</a><wbr><span class="stab deprecated" title="">Deprecated</span></div><div class="desc docblock-short">Bundle for playing a standard bevy audio asset</div></li><li><div class="item-name"><a class="type" href="type.PitchBundle.html" title="type bevy_audio::PitchBundle">Pitch<wbr>Bundle</a><wbr><span class="stab deprecated" title="">Deprecated</span></div><div class="desc docblock-short">Bundle for playing a bevy note sound</div></li></ul></section></div></main></body></html> |