Skip to content

Commit

Permalink
update documentation on AudioSink (#9332)
Browse files Browse the repository at this point in the history
# Objective

When an `AudioSink` is removed from an entity, the audio player will
automatically start any `AudioSource` still attached, which normally is
the one used to start playback in the first place.

## Solution

Long story short, the default behavior is restarting the audio, and this
commit documents that.

---

## Changelog

Fixed documentation on `AudioSink` to clarify removal behavior.
  • Loading branch information
rdrpenguin04 committed Aug 3, 2023
1 parent b6a2fc5 commit 4209819
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/bevy_audio/src/sinks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ pub trait AudioSinkPlayback {
/// Use [`AudioBundle`][crate::AudioBundle] to trigger that to happen.
///
/// You can use this component to modify the playback settings while the audio is playing.
///
/// If this component is removed from an entity, and an [`AudioSource`][crate::AudioSource] is
/// attached to that entity, that [`AudioSource`][crate::AudioSource] will start playing. If
/// that source is unchanged, that translates to the audio restarting.
#[derive(Component)]
pub struct AudioSink {
// This field is an Option in order to allow us to have a safe drop that will detach the sink.
Expand Down Expand Up @@ -128,6 +132,10 @@ impl AudioSinkPlayback for AudioSink {
/// Use [`SpatialAudioBundle`][crate::SpatialAudioBundle] to trigger that to happen.
///
/// You can use this component to modify the playback settings while the audio is playing.
///
/// If this component is removed from an entity, and a [`AudioSource`][crate::AudioSource] is
/// attached to that entity, that [`AudioSource`][crate::AudioSource] will start playing. If
/// that source is unchanged, that translates to the audio restarting.
#[derive(Component)]
pub struct SpatialAudioSink {
// This field is an Option in order to allow us to have a safe drop that will detach the sink.
Expand Down

0 comments on commit 4209819

Please sign in to comment.