From 0f2b7e8227a61c7abb2c272cfff2ef7b7bdbfbf9 Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Wed, 11 Dec 2024 09:16:32 -0700 Subject: [PATCH 1/2] Remove audio TODO and add docs about limitations of PlaybackMode::Once --- crates/bevy_audio/src/audio.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/bevy_audio/src/audio.rs b/crates/bevy_audio/src/audio.rs index 7c020a0333fa2..1e5549c2e92d3 100644 --- a/crates/bevy_audio/src/audio.rs +++ b/crates/bevy_audio/src/audio.rs @@ -36,6 +36,12 @@ impl Volume { #[derive(Debug, Clone, Copy, Reflect)] pub enum PlaybackMode { /// Play the sound once. Do nothing when it ends. + /// + /// NOTE: It is not possible to reuse an `AudioPlayer` after it has finished playing and + /// the underlying `AudioSink` or `SpatialAudioSink` has been drained. + /// + /// To replay a sound, the audio components provided by `AudioPlayer` must be removed and + /// added again. Once, /// Repeat the sound forever. Loop, @@ -77,7 +83,6 @@ pub struct PlaybackSettings { impl Default for PlaybackSettings { fn default() -> Self { - // TODO: what should the default be: ONCE/DESPAWN/REMOVE? Self::ONCE } } From b8d8c0e5f01138d03fdfe4537a0a2c2ff1ce66ef Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Wed, 11 Dec 2024 09:49:57 -0700 Subject: [PATCH 2/2] Docs are duplicated over here --- crates/bevy_audio/src/audio.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/bevy_audio/src/audio.rs b/crates/bevy_audio/src/audio.rs index 1e5549c2e92d3..89bd186e1acbf 100644 --- a/crates/bevy_audio/src/audio.rs +++ b/crates/bevy_audio/src/audio.rs @@ -37,7 +37,7 @@ impl Volume { pub enum PlaybackMode { /// Play the sound once. Do nothing when it ends. /// - /// NOTE: It is not possible to reuse an `AudioPlayer` after it has finished playing and + /// Note: It is not possible to reuse an `AudioPlayer` after it has finished playing and /// the underlying `AudioSink` or `SpatialAudioSink` has been drained. /// /// To replay a sound, the audio components provided by `AudioPlayer` must be removed and @@ -89,6 +89,12 @@ impl Default for PlaybackSettings { impl PlaybackSettings { /// Will play the associated audio source once. + /// + /// Note: It is not possible to reuse an `AudioPlayer` after it has finished playing and + /// the underlying `AudioSink` or `SpatialAudioSink` has been drained. + /// + /// To replay a sound, the audio components provided by `AudioPlayer` must be removed and + /// added again. pub const ONCE: PlaybackSettings = PlaybackSettings { mode: PlaybackMode::Once, volume: Volume(1.0),