Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add AudioWorld#set_master_volume #5

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ use bevy::prelude::*;
use bevy::transform::TransformSystem;
pub use kira;
use kira::manager::{AudioManager, AudioManagerSettings};
use kira::tween::{Tween, Value};
use kira::Volume;

use crate::backend::AudioBackend;
use crate::sources::audio_file::AudioFilePlugin;
Expand Down Expand Up @@ -136,6 +138,17 @@ impl FromWorld for AudioWorld {
}
}

impl AudioWorld {
/// Set the volume of the main track. This will affect all sounds played through the audio plugin.
pub fn set_master_volume(
&mut self,
volume: impl Into<Value<Volume>>,
tween: Tween,
) -> Result<(), kira::CommandError> {
self.audio_manager.main_track().set_volume(volume, tween)
}
}

#[derive(Component)]
#[doc(hidden)]
/// Internal marker for entities with audio components. Needed to be able to query in a
Expand Down
Loading